yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #11377
[Branch ~yade-pkg/yade/git-trunk] Rev 3373: -add saveLatticeNode functions for generating axial-normal slice with "0" and "1"
------------------------------------------------------------
revno: 3373
committer: Chao Yuan <chaoyuan2012@xxxxxxxxx>
timestamp: Mon 2013-06-03 14:20:51 +0200
message:
-add saveLatticeNode functions for generating axial-normal slice with "0" and "1"
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 2013-05-30 16:28:57 +0000
+++ pkg/dem/UnsaturatedEngine.cpp 2013-06-03 12:20:51 +0000
@@ -76,6 +76,13 @@
}
cout << "number_of_cells with air: "<< m <<endl;
+// cout<<"xmin: "<<solver->x_min<<endl;
+// cout<<"xmax: "<<solver->x_max<<endl;
+// cout<<"ymin: "<<solver->y_min<<endl;
+// cout<<"ymax: "<<solver->y_max<<endl;
+// cout<<"zmin: "<<solver->z_min<<endl;
+// cout<<"zmax: "<<solver->z_max<<endl;
+
/* FlowSolver FS;
double surface_tension = 1; //hypothesis that's surface tension
@@ -952,7 +959,7 @@
}
template<class Solver>
-int UnsaturatedEngine::saveListOfNodes(Solver& flow)
+void UnsaturatedEngine::saveListOfNodes(Solver& flow)
{
ofstream file;
file.open("ListOfNodes.txt");
@@ -963,11 +970,10 @@
file << cell->info().index << " " <<cell->neighbor(0)->info().index << " " << cell->neighbor(1)->info().index << " " << cell->neighbor(2)->info().index << " " << cell->neighbor(3)->info().index << endl;
}
file.close();
- return 0;
}
template<class Solver>
-int UnsaturatedEngine::saveListOfConnections(Solver& flow)
+void UnsaturatedEngine::saveListOfConnections(Solver& flow)
{
ofstream file;
file.open("ListOfConnections.txt");
@@ -984,44 +990,127 @@
file << cell->info().index << " " <<cell->neighbor(3)->info().index << " " << surface_tension/cell->info().pore_radius[3] << " " << cell->info().pore_radius[3] << endl;
}
file.close();
- return 0;
-}
-
-/*
-template<class Solver>
-int UnsaturatedEngine::saveLatticeNodes(Solver& flow)
-{
- ofstream file;
- file.open("LatticeNode.txt");
- file << "#Statements Of LatticeNodes: 0 for out of sphere; 1 for inside of sphere \n";
- Real delta_x = 0.1;
- Real delta_y = 0.1;
- Real delta_z = 0.1;
- int N=3;// ?? change according to the scale of model
- for (int i=0; i<N+1; i++) {
- for (int j=0; j<N+1; j++) {
- for (int k=0; k<N+1; k++) {
- double x=i*delta_x;
- double y=j*delta_y;
- double z=k*delta_z;
- Vector3r LatticeNode = Vector3r(x,y,z);
- for (Finite_vertices_iterator V_it = flow->T[flow->currentTes].Triangulation().finite_vertices_begin(); V_it != flow->T[flow->currentTes].Triangulation().finite_vertices_end(); V_it++) {
- Vector3r SphereCenter = makeVector3r2(V_it->point().point());
- if ((LatticeNode-SphereCenter).norm() > pow(V_it->point().weight(),1.0)) {
- file << "0";
- }
- else {
- file << "1";
- }
- }
- }
- file << "\n";
- }
- }
- file.close();
- return 0;
-}
-*/
+}
+
+template<class Solver>
+void UnsaturatedEngine::saveLatticeNodeX(Solver& flow, double x)
+{
+ RTriangulation& tri = flow->T[solver->currentTes].Triangulation();
+ if((x<flow->x_min)||(x>flow->x_max)) {
+ cerr<<"x is out of range! "<<"pleas set x between "<<flow->x_min<<" and "<<flow->x_max<<endl;
+ }
+ else {
+ int N=100;// the default Node number for each slice is 100X100
+ ofstream file;
+ std::ostringstream fileNameStream(".txt");
+ fileNameStream << "LatticeNodeX_"<< x;
+ std::string fileName = fileNameStream.str();
+ file.open(fileName.c_str());
+// file << "#Slice Of LatticeNodes: 0: out of sphere; 1: inside of sphere \n";
+ Real delta_y = (flow->y_max-flow->y_min)/N;
+ Real delta_z = (flow->z_max-flow->z_min)/N;
+ for (int j=0; j<N+1; j++) {
+ for (int k=0; k<N+1; k++) {
+ double y=flow->y_min+j*delta_y;
+ double z=flow->z_min+k*delta_z;
+ int M=0;
+ Vector3r LatticeNode = Vector3r(x,y,z);
+ for (Finite_vertices_iterator V_it = tri.finite_vertices_begin(); V_it != tri.finite_vertices_end(); V_it++) {
+ if(V_it->info().isFictious) continue;
+ Vector3r SphereCenter = makeVector3r2(V_it->point().point());
+ if ((LatticeNode-SphereCenter).squaredNorm() < V_it->point().weight()) {
+ M=1;
+// cerr<<"dfdsf";
+ break;
+ }
+ }
+ file << M;
+ }
+ file << "\n";
+ }
+ file.close();
+ }
+}
+
+template<class Solver>
+void UnsaturatedEngine::saveLatticeNodeY(Solver& flow, double y)
+{
+ RTriangulation& tri = flow->T[solver->currentTes].Triangulation();
+ if((y<flow->y_min)||(y>flow->y_max)) {
+ cerr<<"y is out of range! "<<"pleas set y between "<<flow->y_min<<" and "<<flow->y_max<<endl;
+ }
+ else {
+ int N=100;// the default Node number for each slice is 100X100
+ ofstream file;
+ std::ostringstream fileNameStream(".txt");
+ fileNameStream << "LatticeNodeY_"<< y;
+ std::string fileName = fileNameStream.str();
+ file.open(fileName.c_str());
+// file << "#Slice Of LatticeNodes: 0: out of sphere; 1: inside of sphere \n";
+ Real delta_x = (flow->x_max-flow->x_min)/N;
+ Real delta_z = (flow->z_max-flow->z_min)/N;
+ for (int j=0; j<N+1; j++) {
+ for (int k=0; k<N+1; k++) {
+ double x=flow->x_min+j*delta_x;
+ double z=flow->z_min+k*delta_z;
+ int M=0;
+ Vector3r LatticeNode = Vector3r(x,y,z);
+ for (Finite_vertices_iterator V_it = tri.finite_vertices_begin(); V_it != tri.finite_vertices_end(); V_it++) {
+ if(V_it->info().isFictious) continue;
+ Vector3r SphereCenter = makeVector3r2(V_it->point().point());
+ if ((LatticeNode-SphereCenter).squaredNorm() < V_it->point().weight()) {
+ M=1;
+// cerr<<"dfdsf";
+ break;
+ }
+ }
+ file << M;
+ }
+ file << "\n";
+ }
+ file.close();
+ }
+}
+
+template<class Solver>
+void UnsaturatedEngine::saveLatticeNodeZ(Solver& flow, double z)
+{
+ RTriangulation& tri = flow->T[solver->currentTes].Triangulation();
+ if((z<flow->z_min)||(z>flow->z_max)) {
+ cerr<<"z is out of range! "<<"pleas set z between "<<flow->z_min<<" and "<<flow->z_max<<endl;
+ }
+ else {
+ int N=100;// the default Node number for each slice is 100X100
+ ofstream file;
+ std::ostringstream fileNameStream(".txt");
+ fileNameStream << "LatticeNodeZ_"<< z;
+ std::string fileName = fileNameStream.str();
+ file.open(fileName.c_str());
+// file << "#Slice Of LatticeNodes: 0: out of sphere; 1: inside of sphere \n";
+ Real delta_x = (flow->x_max-flow->x_min)/N;
+ Real delta_y = (flow->y_max-flow->y_min)/N;
+ for (int j=0; j<N+1; j++) {
+ for (int k=0; k<N+1; k++) {
+ double x=flow->x_min+j*delta_x;
+ double y=flow->z_min+k*delta_y;
+ int M=0;
+ Vector3r LatticeNode = Vector3r(x,y,z);
+ for (Finite_vertices_iterator V_it = tri.finite_vertices_begin(); V_it != tri.finite_vertices_end(); V_it++) {
+ if(V_it->info().isFictious) continue;
+ Vector3r SphereCenter = makeVector3r2(V_it->point().point());
+ if ((LatticeNode-SphereCenter).squaredNorm() < V_it->point().weight()) {
+ M=1;
+// cerr<<"dfdsf";
+ break;
+ }
+ }
+ file << M;
+ }
+ file << "\n";
+ }
+ file.close();
+ }
+}
template<class Solver>
void UnsaturatedEngine::setImposedPressure ( unsigned int cond, Real p,Solver& flow )
=== modified file 'pkg/dem/UnsaturatedEngine.hpp'
--- pkg/dem/UnsaturatedEngine.hpp 2013-05-30 16:28:57 +0000
+++ pkg/dem/UnsaturatedEngine.hpp 2013-06-03 12:20:51 +0000
@@ -65,10 +65,12 @@
TPL void invade (Solver& flow );
TPL Real get_min_EntryValue (Solver& flow );
TPL Real getSaturation(Solver& flow);
- TPL int saveListOfNodes(Solver& flow);
- TPL int saveListOfConnections(Solver& flow);
+ TPL void saveListOfNodes(Solver& flow);
+ TPL void saveListOfConnections(Solver& flow);
-// TPL int saveLatticeNodes(Solver& flow); //not work
+ TPL void saveLatticeNodeX(Solver& flow,double x);
+ TPL void saveLatticeNodeY(Solver& flow,double y);
+ TPL void saveLatticeNodeZ(Solver& flow,double z);
template<class Cellhandle>
Real Volume_cell_single_fictious (Cellhandle cell);
template<class Cellhandle>
@@ -103,9 +105,11 @@
void _invade() {invade(solver);}
Real _get_min_EntryValue() {return get_min_EntryValue(solver);}
Real _getSaturation () {return getSaturation(solver);}
- int _saveListOfNodes() {return saveListOfNodes(solver);}
- int _saveListOfConnections() {return saveListOfConnections(solver);}
-// int _saveLatticeNodes() {return saveLatticeNodes(solver);}
+ void _saveListOfNodes() {saveListOfNodes(solver);}
+ void _saveListOfConnections() {saveListOfConnections(solver);}
+ void _saveLatticeNodeX(double x) {saveLatticeNodeX(solver,x);}
+ void _saveLatticeNodeY(double y) {saveLatticeNodeY(solver,y);}
+ void _saveLatticeNodeZ(double z) {saveLatticeNodeZ(solver,z);}
virtual ~UnsaturatedEngine();
@@ -165,8 +169,10 @@
.def("getSaturation",&UnsaturatedEngine::_getSaturation,"get saturation")
.def("getMinEntryValue",&UnsaturatedEngine::_get_min_EntryValue,"get the minimum air entry pressure for the next invade step")
.def("saveListOfNodes",&UnsaturatedEngine::_saveListOfNodes,"Save the list of nodes.")
- .def("saveListOfConnnections",&UnsaturatedEngine::_saveListOfConnections,"Save the connections between cells.")
-// .def("saveLatticeNodes",&UnsaturatedEngine::_saveLatticeNodes,"Save the statement of lattice nodes. 0 for out of sphere; 1 for inside of sphere.")
+ .def("saveListOfConnections",&UnsaturatedEngine::_saveListOfConnections,"Save the connections between cells.")
+ .def("saveLatticeNodeX",&UnsaturatedEngine::_saveLatticeNodeX,(python::arg("x")),"Save the slice of lattice nodes for x_normal(x). 0: out of sphere; 1: inside of sphere.")
+ .def("saveLatticeNodeY",&UnsaturatedEngine::_saveLatticeNodeY,(python::arg("y")),"Save the slice of lattice nodes for y_normal(y). 0: out of sphere; 1: inside of sphere.")
+ .def("saveLatticeNodeZ",&UnsaturatedEngine::_saveLatticeNodeZ,(python::arg("z")),"Save the slice of lattice nodes for z_normal(z). 0: out of sphere; 1: inside of sphere.")
.def("invade",&UnsaturatedEngine::_invade,"Run the drainage invasion from all cells with air pressure. ")
)
DECLARE_LOGGER;