yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #11407
[Branch ~yade-pkg/yade/git-trunk] Rev 3404: clean code.
------------------------------------------------------------
revno: 3404
committer: Chao Yuan <chaoyuan2012@xxxxxxxxx>
timestamp: Mon 2014-02-17 18:42:01 +0100
message:
clean code.
modified:
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/UnsaturatedEngine.cpp'
--- pkg/dem/UnsaturatedEngine.cpp 2014-02-06 18:48:43 +0000
+++ pkg/dem/UnsaturatedEngine.cpp 2014-02-17 17:42:01 +0000
@@ -128,19 +128,18 @@
template<class Solver>
void UnsaturatedEngine::invadeSingleCell2(Cell_handle cell, double pressure, Solver& flow)
{
- double surface_tension = surfaceTension ;
for (int facet = 0; facet < 4; facet ++) {
if (flow->T[flow->currentTes].Triangulation().is_infinite(cell->neighbor(facet))) continue;
if (cell->neighbor(facet)->info().isAirReservoir == true) continue;
if (cell->neighbor(facet)->info().isWaterReservoir == false) continue;
if (cell->neighbor(facet)->info().Pcondition) continue;
- double n_cell_pe = surface_tension/cell->info().poreRadius[facet];
- if (pressure > n_cell_pe) {
- Cell_handle n_cell = cell->neighbor(facet);
- n_cell->info().p() = pressure;
- n_cell->info().isAirReservoir=true;
- n_cell->info().isWaterReservoir=false;
- invadeSingleCell2(n_cell, pressure, flow);
+ double nCellP = surfaceTension/cell->info().poreRadius[facet];
+ if (pressure > nCellP) {
+ Cell_handle nCell = cell->neighbor(facet);
+ nCell->info().p() = pressure;
+ nCell->info().isAirReservoir=true;
+ nCell->info().isWaterReservoir=false;
+ invadeSingleCell2(nCell, pressure, flow);
}
}
}
@@ -180,7 +179,6 @@
{
updateReservoir(flow);
Real nextEntry = 1e50;
- double surface_tension = surfaceTension; //Surface Tension in contact with air at 20 Degrees Celsius is:0.0728(N/m)
RTriangulation& tri = flow->T[flow->currentTes].Triangulation();
Finite_cells_iterator cell_end = tri.finite_cells_end();
for ( Finite_cells_iterator cell = tri.finite_cells_begin(); cell != cell_end; cell++ ) {
@@ -189,7 +187,7 @@
if (tri.is_infinite(cell->neighbor(facet))) continue;
if ( (cell->neighbor(facet)->info().isAirReservoir == true) || (cell->neighbor(facet)->info().isWaterReservoir == false) ) continue;
if (cell->neighbor(facet)->info().Pcondition) continue;
- double n_cell_pe = surface_tension/cell->info().poreRadius[facet];
+ double n_cell_pe = surfaceTension/cell->info().poreRadius[facet];
nextEntry = min(nextEntry,n_cell_pe);
}
}
@@ -1250,8 +1248,6 @@
//reset forces
if (!onlyCache) for (Finite_vertices_iterator v = Tri.finite_vertices_begin(); v != Tri.finite_vertices_end(); ++v) v->info().forces=nullVect;
-// solver->noCache=true;//FIXME:turn true ??(Chao)
-
#ifdef parallel_forces
if (solver->noCache) {
solver->perVertexUnitForce.clear(); solver->perVertexPressure.clear();
@@ -1310,7 +1306,7 @@
}
solver->noCache=false;//cache should always be defined after execution of this function
if (onlyCache) return;
- } else {//use cached values //FIXME:Never run, currently.(chao)
+ } else {//use cached values when triangulation doesn't change
#ifndef parallel_forces
for (Finite_cells_iterator cell = Tri.finite_cells_begin(); cell != cell_end; cell++) {
for (int yy=0;yy<4;yy++) cell->vertex(yy)->info().forces = cell->vertex(yy)->info().forces + cell->info().unitForceVectors[yy]*cell->info().p();}
@@ -1349,49 +1345,6 @@
}
}
-template<class Solver>//tempt test, clean later
-void UnsaturatedEngine::vertxID(Solver& flow)
-{
- ofstream file;
- file.open("vertexID.txt");
- file << "vertexID Pos Force \n";
- RTriangulation& Tri = flow->T[solver->currentTes].Triangulation();
- for (Finite_vertices_iterator v = Tri.finite_vertices_begin(); v != Tri.finite_vertices_end(); ++v) {
- if (!v->info().isFictious) file<<v->info().id()<<" "<<v->point().point()<<" "<<v->info().forces<<endl;
- }
- file.close();
-}
-
-template<class Solver>//tempt test. clean later
-void UnsaturatedEngine::testSolidLine(Solver& flow)
-{
- ofstream file;
- file.open("solidLine.txt");
- file << "cellID facet solidLine[j][0] solidLine[j][1] solidLine[j][2] solidLine[j][3] \n";
- RTriangulation& Tri = flow->T[solver->currentTes].Triangulation();
- for (VCell_iterator cell_it=flow->T[currentTes].cellHandles.begin(); cell_it!=flow->T[currentTes].cellHandles.end(); cell_it++){
- Cell_handle& cell = *cell_it;
- for(int j=0; j<4;j++) {
- file<<cell->info().index<<" "<<j<<" "<<cell->info().solidLine[j][0]<<" "<<cell->info().solidLine[j][1]<<" "<<cell->info().solidLine[j][2]<<" "<<cell->info().solidLine[j][3]<<endl;
- }
- }
- file.close();
-}
-
-template<class Solver>
-void UnsaturatedEngine::testReservoirAttr(Solver& flow)
-{
- ofstream file;
- file.open("reservoir.txt");
- file << "cellID isWaterReservoir isAirReservoir \n";
- RTriangulation& Tri = flow->T[solver->currentTes].Triangulation();
- Finite_cells_iterator cell_end = Tri.finite_cells_end();
- for (Finite_cells_iterator cell = Tri.finite_cells_begin(); cell != cell_end; cell++) {
- file<<cell->info().index<<" "<<cell->info().isWaterReservoir<<" "<<cell->info().isAirReservoir<<endl;
- }
- file.close();
-}
-
YADE_PLUGIN ( ( UnsaturatedEngine ) );
#endif //FLOW_ENGINE
=== modified file 'pkg/dem/UnsaturatedEngine.hpp'
--- pkg/dem/UnsaturatedEngine.hpp 2014-02-06 18:48:43 +0000
+++ pkg/dem/UnsaturatedEngine.hpp 2014-02-17 17:42:01 +0000
@@ -91,15 +91,11 @@
TPL void savePoreThroatInfo(Solver& flow);
TPL void debugTemp(Solver& flow);
- TPL void vertxID(Solver& flow);
- TPL void testSolidLine(Solver& flow);
TPL void computeSolidLine(Solver& flow);
TPL void computeFacetPoreForcesWithCache(Solver& flow, bool onlyCache=false);
- TPL void testReservoirAttr(Solver& flow);
TPL Vector3r fluidForce(unsigned int id_sph, Solver& flow) {
const CGT::Vecteur& f=flow->T[flow->currentTes].vertex(id_sph)->info().forces; return Vector3r(f[0],f[1],f[2]);}
- TPL bool testNoCache(Solver&flow){bool testnoCache=flow->noCache; return testnoCache;}//clean later
template<class Cellhandle >
double getRadiusMin(Cellhandle cell, int j);
@@ -156,25 +152,20 @@
void _savePoreThroatInfo(){savePoreThroatInfo(solver);}
void _debugTemp(){debugTemp(solver);}
void _computeFacetPoreForcesWithCache(){computeFacetPoreForcesWithCache(solver);}
- void _vertxID(){vertxID(solver);}
- void _testSolidLine(){testSolidLine(solver);}
Vector3r _fluidForce(unsigned int id_sph) {return fluidForce(id_sph,solver);}
- bool _testNoCache() {return testNoCache(solver);}
- void _testReservoir() {return testReservoirAttr(solver);}
virtual ~UnsaturatedEngine();
virtual void action();
YADE_CLASS_BASE_DOC_ATTRS_DEPREC_INIT_CTOR_PY(UnsaturatedEngine,PartialEngine,"Preliminary version engine of a model for unsaturated soils",
-// ((bool,drainageActivated,true,,"Activate drainage"))//use later
-// ((bool,imbibitionActivated,true,,"Activate imbibition"))//use later
+ ((bool,isActivated,true,,"Activate UnsaturatedEngine."))
((bool,first,true,,"Controls the initialization/update phases"))
((bool, Debug, false,,"Activate debug messages"))
((double, wall_thickness,0.001,,"Walls thickness"))
((double,P_zero,0,,"The value used for initializing pore pressure. It is useless for incompressible fluid, but important for compressible model."))
((double,gasPressure,0,,"Invasion pressure"))
- ((double,surfaceTension,0.0728,,"Surface Tension in contact with air at 20 Degrees Celsius is: 0.0728(N/m)"))
+ ((double,surfaceTension,0.0728,,"Water Surface Tension in contact with air at 20 Degrees Celsius is: 0.0728(N/m)"))
((double, porosity, 0,,"Porosity computed at each retriangulation"))
((int, xmin,0,(Attr::readonly),"Index of the boundary $x_{min}$. This index is not equal the the id of the corresponding body in general, it may be used to access the corresponding attributes (e.g. flow.bndCondValue[flow.xmin], flow.wallId[flow.xmin],...)."))
((int, xmax,1,(Attr::readonly),"See :yref:`FlowEngine::xmin`."))
@@ -194,11 +185,6 @@
,
/*deprec*/
,,
-// for (int i=0; i<6; ++i){normal[i]=Vector3r::Zero();}
-// normal[wall_bottom].y()=normal[wall_left].x()=normal[wall_back].z()=1;
-// normal[wall_top].y()=normal[wall_right].x()=normal[wall_front].z()=-1;
-// solver = shared_ptr<FlowSolver> (new FlowSolver);
-// first=true;
for (int i=0; i<6; ++i){normal[i]=Vector3r::Zero(); wallIds[i]=i;}
normal[wall_ymin].y()=normal[wall_xmin].x()=normal[wall_zmin].z()=1;
normal[wall_ymax].y()=normal[wall_xmax].x()=normal[wall_zmax].z()=-1;
@@ -231,11 +217,7 @@
.def("invade",&UnsaturatedEngine::_invade,"Run the drainage invasion from all cells with air pressure. ")
.def("invade2",&UnsaturatedEngine::_invade2,"Run the drainage invasion from all cells with air pressure.(version2,water can be trapped in cells) ")
.def("computeForce",&UnsaturatedEngine::_computeFacetPoreForcesWithCache,"Test computeFacetPoreForcesWithCache(). ")
- .def("vertxID",&UnsaturatedEngine::_vertxID,"cout vertxID. ")
- .def("testSolidLine",&UnsaturatedEngine::_testSolidLine,"For checking solidLine.")
.def("fluidForce",&UnsaturatedEngine::_fluidForce,(python::arg("Id_sph")),"Return the fluid force on sphere Id_sph.")
- .def("testNoCache",&UnsaturatedEngine::_testNoCache, "test noCache.")
- .def("testReservoirAttr",&UnsaturatedEngine::_testReservoir, "test reservoir attributes.")
)
DECLARE_LOGGER;
};