yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #03661
[Branch ~yade-dev/yade/trunk] Rev 2102: 1. Move SpherePadder from extra to py/pack/SpherePadder
------------------------------------------------------------
revno: 2102
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-03-25 14:24:10 +0100
message:
1. Move SpherePadder from extra to py/pack/SpherePadder
2. Add py/pack directory, to avoid too many files in py
3. Other small fixes
removed:
extra/SpherePadder/Makefile
extra/SpherePadder/SpherePackingTriangulation/makefile
added:
py/pack/
py/pack/SpherePadder/
renamed:
extra/SpherePadder/CellPartition.cpp => py/pack/SpherePadder/CellPartition.cpp
extra/SpherePadder/CellPartition.hpp => py/pack/SpherePadder/CellPartition.hpp
extra/SpherePadder/SpherePackingTriangulation/SpherePackingTriangulation.cpp => py/pack/SpherePadder/SpherePackingTriangulation.cpp
extra/SpherePadder/SpherePackingTriangulation/SpherePackingTriangulation.hpp => py/pack/SpherePadder/SpherePackingTriangulation.hpp
extra/SpherePadder/SpherePadder.cpp => py/pack/SpherePadder/SpherePadder.cpp
extra/SpherePadder/SpherePadder.hpp => py/pack/SpherePadder/SpherePadder.hpp
extra/SpherePadder/SpherePadder_wrapper.cpp => py/pack/_packSpherePadder.cpp
extra/SpherePadder/TetraMesh.cpp => py/pack/SpherePadder/TetraMesh.cpp
extra/SpherePadder/TetraMesh.hpp => py/pack/SpherePadder/TetraMesh.hpp
extra/SpherePadder/main.cpp => py/pack/SpherePadder/main.cpp
py/_packObb.cpp => py/pack/_packObb.cpp
py/_packPredicates.cpp => py/pack/_packPredicates.cpp
py/_packSpheres.cpp => py/pack/_packSpheres.cpp
py/pack.py => py/pack/pack.py
modified:
debian/rules
pkg/dem/Engine/GlobalEngine/ElasticContactLaw.cpp
pkg/dem/Engine/GlobalEngine/NewtonIntegrator.cpp
py/SConscript
py/timing.py
py/yadeWrapper/yadeWrapper.cpp
py/pack/SpherePadder/CellPartition.hpp
py/pack/SpherePadder/SpherePackingTriangulation.hpp
py/pack/SpherePadder/SpherePadder.cpp
py/pack/SpherePadder/SpherePadder.hpp
py/pack/_packSpherePadder.cpp
py/pack/_packPredicates.cpp
py/pack/pack.py
--
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 'debian/rules'
--- debian/rules 2010-03-22 12:32:38 +0000
+++ debian/rules 2010-03-25 13:24:10 +0000
@@ -59,7 +59,7 @@
### (a) use fakeroot-tcp instead of fakeroot
### (b) use just 1 job
#debug build
- NO_SCONS_GET_RECENT= scons buildPrefix=debian runtimePREFIX=/usr version=${VERSION} brief=0 chunkSize=-1 linkStrategy=monolithic features=vtk,gts,log4cxx,opengl,openmp,boost-serialization exclude=snow PREFIX=debian/yade${_VERSION}-dbg/usr variant=-dbg optimize=0 march= debug=1
+ NO_SCONS_GET_RECENT= scons buildPrefix=debian runtimePREFIX=/usr version=${VERSION} brief=0 chunkSize=20 linkStrategy=monolithic features=vtk,gts,log4cxx,opengl,openmp exclude=snow PREFIX=debian/yade${_VERSION}-dbg/usr variant=-dbg optimize=0 march= debug=1
#optimized build
NO_SCONS_GET_RECENT= scons PREFIX=debian/yade${_VERSION}/usr variant='' optimize=1 debug=0
#install platform-independent files (docs, scripts, examples)
=== removed file 'extra/SpherePadder/Makefile'
--- extra/SpherePadder/Makefile 2009-05-28 12:44:55 +0000
+++ extra/SpherePadder/Makefile 1970-01-01 00:00:00 +0000
@@ -1,78 +0,0 @@
-CC = g++
-CFLAGS = -fpic -O3 -Wall
-LFLAGS = -lCGAL -lm
-
-SRC = main.cpp \
- SpherePadder.cpp TetraMesh.cpp CellPartition.cpp
-
-OBJS = $(subst .cpp,.o,$(SRC))
-
-.SUFFIXES: .cpp
-.cpp.o:
- $(CC) -c $(CFLAGS) $<
-
-all: $(OBJS)
- $(CC) -o pad $(OBJS) ./SpherePackingTriangulation/SpherePackingTriangulation.o $(LFLAGS)
-
-pymod: $(SRC) SpherePadder_wrapper.cpp
- $(CC) SpherePadder_wrapper.cpp -shared -o packing.so $(OBJS) ./SpherePackingTriangulation/SpherePackingTriangulation.o -lboost_python -I/usr/include/python2.5 -lCGAL
-
-clean:
- rm -f *~ \#*\#
- rm -f *.o
-
-depend:
- makedepend -- $(CFLAGS) -- *.cpp
-
-# DON'T FORGET TO TYPE make depend AT FIRST COMPILATION
-# DO NOT DELETE
-
-CellPartition.o: CellPartition.hpp TetraMesh.hpp /usr/include/stdlib.h
-CellPartition.o: /usr/include/features.h /usr/include/sys/cdefs.h
-CellPartition.o: /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h
-CellPartition.o: /usr/include/gnu/stubs-32.h /usr/include/sys/types.h
-CellPartition.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
-CellPartition.o: /usr/include/time.h /usr/include/endian.h
-CellPartition.o: /usr/include/bits/endian.h /usr/include/sys/select.h
-CellPartition.o: /usr/include/bits/select.h /usr/include/bits/sigset.h
-CellPartition.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h
-CellPartition.o: /usr/include/bits/pthreadtypes.h /usr/include/alloca.h
-CellPartition.o: /usr/include/math.h /usr/include/bits/huge_val.h
-CellPartition.o: /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h
-SpherePadder.o: SpherePadder.hpp TetraMesh.hpp /usr/include/stdlib.h
-SpherePadder.o: /usr/include/features.h /usr/include/sys/cdefs.h
-SpherePadder.o: /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h
-SpherePadder.o: /usr/include/gnu/stubs-32.h /usr/include/sys/types.h
-SpherePadder.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
-SpherePadder.o: /usr/include/time.h /usr/include/endian.h
-SpherePadder.o: /usr/include/bits/endian.h /usr/include/sys/select.h
-SpherePadder.o: /usr/include/bits/select.h /usr/include/bits/sigset.h
-SpherePadder.o: /usr/include/bits/time.h /usr/include/sys/sysmacros.h
-SpherePadder.o: /usr/include/bits/pthreadtypes.h /usr/include/alloca.h
-SpherePadder.o: /usr/include/math.h /usr/include/bits/huge_val.h
-SpherePadder.o: /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h
-SpherePadder.o: CellPartition.hpp
-TetraMesh.o: TetraMesh.hpp /usr/include/stdlib.h /usr/include/features.h
-TetraMesh.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
-TetraMesh.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
-TetraMesh.o: /usr/include/sys/types.h /usr/include/bits/types.h
-TetraMesh.o: /usr/include/bits/typesizes.h /usr/include/time.h
-TetraMesh.o: /usr/include/endian.h /usr/include/bits/endian.h
-TetraMesh.o: /usr/include/sys/select.h /usr/include/bits/select.h
-TetraMesh.o: /usr/include/bits/sigset.h /usr/include/bits/time.h
-TetraMesh.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h
-TetraMesh.o: /usr/include/alloca.h /usr/include/math.h
-TetraMesh.o: /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h
-TetraMesh.o: /usr/include/bits/mathcalls.h
-main.o: SpherePadder.hpp TetraMesh.hpp /usr/include/stdlib.h
-main.o: /usr/include/features.h /usr/include/sys/cdefs.h
-main.o: /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h
-main.o: /usr/include/gnu/stubs-32.h /usr/include/sys/types.h
-main.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
-main.o: /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h
-main.o: /usr/include/sys/select.h /usr/include/bits/select.h
-main.o: /usr/include/bits/sigset.h /usr/include/bits/time.h
-main.o: /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h
-main.o: /usr/include/alloca.h /usr/include/math.h
-main.o: /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h
-main.o: /usr/include/bits/mathcalls.h CellPartition.hpp
=== removed file 'extra/SpherePadder/SpherePackingTriangulation/makefile'
--- extra/SpherePadder/SpherePackingTriangulation/makefile 2009-02-24 09:06:00 +0000
+++ extra/SpherePadder/SpherePackingTriangulation/makefile 1970-01-01 00:00:00 +0000
@@ -1,61 +0,0 @@
-# Created by the script cgal_create_makefile
-# This is the makefile for compiling a CGAL application.
-
-#---------------------------------------------------------------------#
-# include platform specific settings
-#---------------------------------------------------------------------#
-# Choose the right include file from the <cgalroot>/make directory.
-
-# CGAL_MAKEFILE = ENTER_YOUR_INCLUDE_MAKEFILE_HERE
-ifndef CGAL_MAKEFILE
-CGAL_MAKEFILE = /usr/share/cgal/cgal.mk
-endif
-include $(CGAL_MAKEFILE)
-
-#---------------------------------------------------------------------#
-# compiler flags
-#---------------------------------------------------------------------#
-
-CXXFLAGS = \
- $(CGAL_CXXFLAGS) \
- $(LONG_NAME_PROBLEM_CXXFLAGS)
-
-#---------------------------------------------------------------------#
-# linker flags
-#---------------------------------------------------------------------#
-
-LIBPATH = \
- $(CGAL_LIBPATH)
-
-LDFLAGS = \
- $(LONG_NAME_PROBLEM_LDFLAGS) \
- $(CGAL_LDFLAGS)
-
-#---------------------------------------------------------------------#
-# target entries
-#---------------------------------------------------------------------#
-
-all: SpherePackingTriangulation.o
- # test$(EXE_EXT)
-
-SpherePackingTriangulation.o: SpherePackingTriangulation.cpp SpherePackingTriangulation.hpp
- $(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) SpherePackingTriangulation.cpp
-
-#test$(EXE_EXT): test$(OBJ_EXT) SpherePackingTriangulation.o
-# $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)test test$(OBJ_EXT) SpherePackingTriangulation.o $(LDFLAGS)
-
-clean: \
- SpherePackingTriangulation.clean
- # test.clean
-
-#---------------------------------------------------------------------#
-# suffix rules
-#---------------------------------------------------------------------#
-
-.C$(OBJ_EXT):
- $(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $<
-
-
-.cpp$(OBJ_EXT):
- $(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $<
-
=== modified file 'pkg/dem/Engine/GlobalEngine/ElasticContactLaw.cpp'
--- pkg/dem/Engine/GlobalEngine/ElasticContactLaw.cpp 2010-03-20 12:40:44 +0000
+++ pkg/dem/Engine/GlobalEngine/ElasticContactLaw.cpp 2010-03-25 13:24:10 +0000
@@ -104,7 +104,7 @@
phys->normalForce=phys->kn*displN*geom->normal;
Real maxFsSq=phys->normalForce.SquaredLength()*pow(phys->tangensOfFrictionAngle,2);
Vector3r trialFs=phys->ks*geom->displacementT();
- if(trialFs.SquaredLength()>maxFsSq){ geom->slipToDisplacementTMax(sqrt(maxFsSq)); trialFs*=sqrt(maxFsSq/(trialFs.SquaredLength()));}
+ if(trialFs.SquaredLength()>maxFsSq){ geom->slipToDisplacementTMax(sqrt(maxFsSq)/phys->ks); trialFs*=sqrt(maxFsSq/(trialFs.SquaredLength()));}
phys->shearForce=trialFs;
applyForceAtContactPoint(phys->normalForce+trialFs,geom->contactPoint,contact->getId1(),geom->se31.position,contact->getId2(),geom->se32.position,scene);
}
=== modified file 'pkg/dem/Engine/GlobalEngine/NewtonIntegrator.cpp'
--- pkg/dem/Engine/GlobalEngine/NewtonIntegrator.cpp 2010-03-20 12:40:44 +0000
+++ pkg/dem/Engine/GlobalEngine/NewtonIntegrator.cpp 2010-03-25 13:24:10 +0000
@@ -179,7 +179,8 @@
{
blockTranslateDOFs(state->blockedDOFs, state->accel);
state->vel+=dt*state->accel;
- state->pos += state->vel*dt + scene->forces.getMove(id);
+ state->pos += state->vel*dt;
+ if(scene->forces.getMoveRotUsed()) state->pos+=scene->forces.getMove(id);
assert(homotheticCellResize>=0 && homotheticCellResize<=2);
if(homotheticCellResize>0){
//Vector3r dPos(scene->cell->getTrsfInc()*scene->cell->wrapShearedPt(state->pos));
@@ -223,7 +224,7 @@
const Vector3r l_b_n = A*l_n; // local angular momentum at time n
const Vector3r angVel_b_n = diagDiv(l_b_n,state->inertia); // local angular velocity at time n
const Quaternionr dotQ_n=DotQ(angVel_b_n,state->ori); // dQ/dt at time n
- const Quaternionr Q_half = state->ori + dt/2 * dotQ_n; // Q at time n+1/2 // FIXME: this is nonsense, quaternions cannot be meaningfully mutiplied by scalars, since they are not normalized afterwards (not pure rotation, but also skew); use slerp with parameter .5 to find half-way quaternion.
+ const Quaternionr Q_half = state->ori + dt/2 * dotQ_n; // Q at time n+1/2
state->angMom+=dt*M; // global angular momentum at time n+1/2
const Vector3r l_b_half = A*state->angMom; // local angular momentum at time n+1/2
Vector3r angVel_b_half = diagDiv(l_b_half,state->inertia); // local angular velocity at time n+1/2
=== modified file 'py/SConscript'
--- py/SConscript 2010-03-20 12:40:44 +0000
+++ py/SConscript 2010-03-25 13:24:10 +0000
@@ -12,14 +12,15 @@
env.SharedLibrary('_utils',['_utils.cpp'],SHLIBPREFIX='',LIBS=env['LIBS']+[
linkPlugins(['Shop','ConcretePM','Facet']),
]),
- env.SharedLibrary('_packPredicates',['_packPredicates.cpp'],SHLIBPREFIX='',
+ env.SharedLibrary('_packPredicates',['pack/_packPredicates.cpp'],SHLIBPREFIX='',
# link to the symlink to the python module (created in lib/SConstruct; see explanation there)
LIBS=env['LIBS']+(['_gts__python-module'] if 'YADE_GTS' in env['CPPDEFINES'] else []),
),
- env.SharedLibrary('_packSpheres',['_packSpheres.cpp'],SHLIBPREFIX='',LIBS=env['LIBS']+[
+ env.SharedLibrary('_packSpherePadder',env.Combine('packSpherePadder.cpp',['pack/_packSpherePadder.cpp','pack/SpherePadder/SpherePadder.cpp','pack/SpherePadder/TetraMesh.cpp','pack/SpherePadder/CellPartition.cpp']+(['pack/SpherePadder/SpherePackingTriangulation.cpp'] if 'cgal' in env['features'] else [])),SHLIBPREFIX='',LIBS=env['LIBS']+linkPlugins(['SpherePack'])),
+ env.SharedLibrary('_packSpheres',['pack/_packSpheres.cpp'],SHLIBPREFIX='',LIBS=env['LIBS']+[
linkPlugins(['Shop','SpherePack']),
]),
- env.SharedLibrary('_packObb',['_packObb.cpp'],SHLIBPREFIX=''),
+ env.SharedLibrary('_packObb',['pack/_packObb.cpp'],SHLIBPREFIX=''),
env.AlwaysBuild(env.ScanReplace('__init__.py.in')),
env.AlwaysBuild(env.ScanReplace('config.py.in')),
env.File('utils.py'),
@@ -29,14 +30,13 @@
env.File('plot.py'),
env.File('linterpolation.py'),
env.File('timing.py'),
- env.File('pack.py'),
+ env.File('pack/pack.py'),
env.File('remote.py'),
env.File('system.py'),
env.File('export.py'),
env.File('post2d.py'),
env.File('_extraDocs.py'),
- #env.File('ww.py'),
- env.SharedLibrary('wrapper',['yadeWrapper/yadeWrapper.cpp'],SHLIBPREFIX='',LIBS=['PythonUI']+linkPlugins(['Shop','BoundDispatcher','InteractionGeometryDispatcher','InteractionPhysicsDispatcher','LawDispatcher','InteractionDispatchers','ParallelEngine','Clump','STLImporter',]+(['GeometricalModelMetaEngine','InteractingGeometryMetaEngine',] if 'geometricalmodel' in env['features'] else [])+(['StateMetaEngine',] if 'physpar' in env['features'] else []))),
+ env.SharedLibrary('wrapper',['yadeWrapper/yadeWrapper.cpp'],SHLIBPREFIX='',LIBS=['PythonUI']+linkPlugins(['Shop','BoundDispatcher','InteractionGeometryDispatcher','InteractionPhysicsDispatcher','LawDispatcher','InteractionDispatchers','ParallelEngine','Clump','STLImporter',])),
env.SharedLibrary('_customConverters',['yadeWrapper/customConverters.cpp'],SHLIBPREFIX='',LIBS=env['LIBS']+linkPlugins(Split("BoundFunctor InteractionGeometryFunctor InteractionPhysicsFunctor LawFunctor")))
])
env.Install('$PREFIX/lib/yade$SUFFIX/py/yade/tests',[
=== added directory 'py/pack'
=== added directory 'py/pack/SpherePadder'
=== renamed file 'extra/SpherePadder/CellPartition.cpp' => 'py/pack/SpherePadder/CellPartition.cpp'
=== renamed file 'extra/SpherePadder/CellPartition.hpp' => 'py/pack/SpherePadder/CellPartition.hpp'
--- extra/SpherePadder/CellPartition.hpp 2009-05-28 12:44:55 +0000
+++ py/pack/SpherePadder/CellPartition.hpp 2010-03-25 13:24:10 +0000
@@ -7,19 +7,18 @@
* This program is free software; it is licensed under the terms of the *
* GNU General Public License v2 or later. See file LICENSE for details. *
*************************************************************************/
-
-#ifndef CELL_PARTITION_HPP
-#define CELL_PARTITION_HPP
+#pragma once
#include "TetraMesh.hpp"
-struct Cell
-{
- vector<unsigned int> sphereId;
-};
-
class CellPartition
{
+ public:
+ struct Cell
+ {
+ vector<unsigned int> sphereId;
+ };
+
protected:
vector<vector<vector<unsigned int> > > cellId;
@@ -55,5 +54,3 @@
unsigned int k_up () { return ( (current_k < ksize - 1) ? (current_k + 1) : ksize - 1); }
};
-#endif // CELL_PARTITION_HPP
-
=== renamed file 'extra/SpherePadder/SpherePackingTriangulation/SpherePackingTriangulation.cpp' => 'py/pack/SpherePadder/SpherePackingTriangulation.cpp'
=== renamed file 'extra/SpherePadder/SpherePackingTriangulation/SpherePackingTriangulation.hpp' => 'py/pack/SpherePadder/SpherePackingTriangulation.hpp'
--- extra/SpherePadder/SpherePackingTriangulation/SpherePackingTriangulation.hpp 2009-04-06 14:42:25 +0000
+++ py/pack/SpherePadder/SpherePackingTriangulation.hpp 2010-03-25 13:24:10 +0000
@@ -1,5 +1,4 @@
-#ifndef SPHERE_PACKING_TRIANGULATION_HPP
-#define SPHERE_PACKING_TRIANGULATION_HPP
+#pragma once
//#include <vector>
#include <map>
@@ -125,6 +124,3 @@
};
-
-
-#endif // SPHERE_PACKING_TRIANGULATION_HPP
=== renamed file 'extra/SpherePadder/SpherePadder.cpp' => 'py/pack/SpherePadder/SpherePadder.cpp'
--- extra/SpherePadder/SpherePadder.cpp 2009-05-28 12:44:55 +0000
+++ py/pack/SpherePadder/SpherePadder.cpp 2010-03-25 13:24:10 +0000
@@ -10,6 +10,11 @@
#include "SpherePadder.hpp"
+CREATE_LOGGER(SpherePadder);
+
+#include<boost/algorithm/string.hpp>
+#include<stdexcept>
+
int compare_neighbor_with_distance (const void * a, const void * b)
{
double d1 = (*(neighbor_with_distance *)a).distance;
@@ -35,8 +40,7 @@
return ( *(double*)a > *(double*)b ) ? 1 :-1;
}
-
-SpherePadder::SpherePadder()
+void SpherePadder::init()
{
vector <id_type> lst;
id_type nb = 5;
@@ -63,7 +67,6 @@
n1 = n2 = n3 = n4 = n5 = n_densify = 0;
// Default values
- verbose = true;
meshIsPlugged = false;
RadiusDataIsOK = RadiusIsSet = false;
max_overlap_rate = 1e-4;
@@ -74,6 +77,21 @@
Must_Stop = false;
zmin = 1;
gap_max = 0.0;
+ mesh=NULL;
+}
+
+SpherePadder::SpherePadder(const std::string& fileName, std::string meshType){
+ init();
+ if(meshType.empty()){
+ if(boost::algorithm::ends_with(fileName,".gmsh") || boost::algorithm::ends_with(fileName,".geo")) meshType="GMSH";
+ else if(boost::algorithm::ends_with(fileName,".inp")) meshType=="INP";
+ else throw std::invalid_argument("Unable to deduce mesh type from extension (should be *.gmsh or *.geo for GMSH, *.inp for INP); specify meshType explicitly.");
+ }
+ if(meshType!="GMSH" && meshType!="INP") throw std::invalid_argument("Unknown mesh type '"+meshType+"'. Must be one of GMSH, INP (case sensitive).");
+ TetraMesh* m=new TetraMesh; // dtor will delete
+ if(meshType=="GMSH") m->read_gmsh(fileName.c_str());
+ else if(meshType=="INP") m->read_inp(fileName.c_str());
+ plugTetraMesh(m);
}
@@ -90,13 +108,10 @@
rmax = 2.0 * rmoy - rmin;
gap_max = rmin;
RadiusDataIsOK = true;
- if (verbose)
- {
- cout << "rmin = " << rmin << endl;
- cout << "rmax = " << rmax << endl;
- cout << "rmoy = " << rmoy << endl;
- cout << "ratio = " << ratio << endl;
- }
+ LOG_DEBUG("rmin = " << rmin);
+ LOG_DEBUG("rmax = " << rmax);
+ LOG_DEBUG("rmoy = " << rmoy);
+ LOG_DEBUG("ratio = " << ratio);
}
else
{
@@ -126,13 +141,10 @@
RadiusDataIsOK = true;
RadiusIsSet = true;
- if (verbose)
- {
- cout << "rmin = " << rmin << endl;
- cout << "rmax = " << rmax << endl;
- cout << "rmoy = " << rmoy << endl;
- cout << "ratio = " << ratio << endl;
- }
+ LOG_DEBUG("rmin = " << rmin);
+ LOG_DEBUG("rmax = " << rmax);
+ LOG_DEBUG("rmoy = " << rmoy);
+ LOG_DEBUG("ratio = " << ratio);
}
@@ -169,16 +181,15 @@
void SpherePadder::plugTetraMesh (TetraMesh * pluggedMesh)
{
+ // delete old mesh
+ if(mesh) delete mesh;
mesh = pluggedMesh;
partition.init(*mesh);
meshIsPlugged = true;
- if (verbose)
- {
- cout << "mesh->mean_segment_length = " << mesh->mean_segment_length << endl;
- cout << "mesh->min_segment_length = " << mesh->min_segment_length << endl;
- cout << "mesh->max_segment_length = " << mesh->max_segment_length << endl;
- }
+ LOG_DEBUG("mesh->mean_segment_length = " << mesh->mean_segment_length);
+ LOG_DEBUG("mesh->min_segment_length = " << mesh->min_segment_length);
+ LOG_DEBUG("mesh->max_segment_length = " << mesh->max_segment_length);
if (!RadiusDataIsOK && RadiusIsSet && ratio != 0.0) setRadiusRatio(ratio);
}
@@ -215,26 +226,26 @@
if (sphere[i].R <= 0.0) ++nzero;
}
- if (verbose)
- {
- cout << "Summary:" << endl;
- cout << " Total number of spheres = " << sphere.size()-nzero << endl;
- cout << " Number at nodes = " << n1 << endl;
- cout << " Number at segments = " << n2 << endl;
- cout << " Number near faces = " << n3 << endl;
- cout << " Number near tetra centers = " << n4 << endl;
- cout << " Number near tetra vextexes = " << n5 << endl;
- cout << " Number cancelled = " << nzero << endl;
- }
+ LOG_INFO("Summary:" << endl
+ << " Total number of spheres = " << sphere.size()-nzero << endl
+ << " Number at nodes = " << n1 << endl
+ << " Number at segments = " << n2 << endl
+ << " Number near faces = " << n3 << endl
+ << " Number near tetra centers = " << n4 << endl
+ << " Number near tetra vextexes = " << n5 << endl
+ << " Number cancelled = " << nzero);
float time_used = (float)(stop_time - start_time) / 1000000.0;
- if (verbose) cout << "Time used (pad5) = " << time_used << " s" << endl;
+ LOG_INFO("Time used (pad5) = " << time_used << " s");
}
void SpherePadder::densify() // makeDenser
{
+#ifndef YADE_CGAL
+ throw std::runtime_error("Yade was built without CGAL, mesh densification impossible.");
+#else
BEGIN_FUNCTION ("Densify");
unsigned int added = 0;
unsigned int nbfail = 0;
@@ -261,6 +272,7 @@
cout << "Final solid fraction = " << getMeanSolidFraction(criterion.x,criterion.y,criterion.z,criterion.R) << endl;
END_FUNCTION;
+#endif
}
@@ -291,7 +303,7 @@
//}
}
-
+#ifdef YADE_CGAL
unsigned int SpherePadder::iter_densify (unsigned int nb_check) // iter_MakeDenser
{
unsigned int nb_added = 0, total_added = 0;
@@ -399,6 +411,7 @@
return total_added;
}
+#endif
double SpherePadder::getMeanSolidFraction(double x, double y, double z, double R)
@@ -463,7 +476,7 @@
return (Vs/Vp);
}
-
+#ifdef YADE_CGAL
void SpherePadder::save_tri_mgpost (const char* name)
{
// triangulation
@@ -520,13 +533,13 @@
<< " </mgpost>" << endl;
}
-
-
-void SpherePadder::save_mgpost (const char* name)
+#endif
+
+void SpherePadder::save_mgpost (std::string name)
{
BEGIN_FUNCTION ("Save mgp");
- ofstream fmgpost(name);
+ ofstream fmgpost(name.c_str());
double xtrans = mesh->xtrans;
double ytrans = mesh->ytrans;
@@ -642,10 +655,7 @@
partition.add(n,S.x,S.y,S.z);
}
- if (verbose)
- {
- cout << " Added = " << n1 << endl;
- }
+ LOG_DEBUG(" Added = " << n1);
END_FUNCTION;
}
@@ -688,10 +698,7 @@
++ns;
}
- if (verbose)
- {
- cout << " Added = " << n2 << endl;
- }
+ LOG_DEBUG("Added = " << n2);
END_FUNCTION;
}
@@ -732,10 +739,7 @@
n3 += place_sphere_4contacts(S);
}
- if (verbose)
- {
- cout << " Added = " << n3 << endl;
- }
+ LOG_DEBUG(" Added = " << n3);
END_FUNCTION;
}
@@ -767,10 +771,7 @@
n4 += place_sphere_4contacts(S);
}
- if (verbose)
- {
- cout << " Added = " << n4 << endl;
- }
+ LOG_DEBUG(" Added = " << n4);
END_FUNCTION;
}
@@ -811,10 +812,7 @@
}
}
- if (verbose)
- {
- cout << " Added = " << n5 << endl;
- }
+ LOG_DEBUG(" Added = " << n5);
END_FUNCTION;
}
@@ -1932,7 +1930,12 @@
}
-
-
-
-
+SpherePack SpherePadder::getSpherePackObject(){
+ SpherePack ret;
+ Vector3r trans(getMesh()->xtrans,getMesh()->ytrans,getMesh()->ztrans);
+ for(size_t i=0; i<sphere.size(); i++){
+ if (sphere[i].type == VIRTUAL || sphere[i].R <= 0.0) continue;
+ ret.pack.push_back(SpherePack::Sph(Vector3r(sphere[i].x,sphere[i].y,sphere[i].z)+trans,sphere[i].R));
+ }
+ return ret;
+}
=== renamed file 'extra/SpherePadder/SpherePadder.hpp' => 'py/pack/SpherePadder/SpherePadder.hpp'
--- extra/SpherePadder/SpherePadder.hpp 2009-05-29 07:42:46 +0000
+++ py/pack/SpherePadder/SpherePadder.hpp 2010-03-25 13:24:10 +0000
@@ -10,15 +10,25 @@
#pragma once
+#include<yade/lib-base/Logging.hpp>
+#include<yade/lib-base/Math.hpp>
+#include<yade/pkg-dem/SpherePack.hpp>
+
#include "TetraMesh.hpp"
#include "CellPartition.hpp"
-#include "SpherePackingTriangulation/SpherePackingTriangulation.hpp"
+#ifdef YADE_CGAL
+ #include "SpherePackingTriangulation.hpp"
+#endif
#include <time.h>
#include <set>
#include <list>
-# define BEGIN_FUNCTION(arg) if (verbose) cout << "+--> " << (arg) << endl << flush
-# define END_FUNCTION if (verbose) cout << "+-- Done <--+\n\n" << flush
+#include <boost/python.hpp>
+
+namespace py=boost::python;
+
+# define BEGIN_FUNCTION(arg) LOG_TRACE("+--> "<<arg)
+# define END_FUNCTION LOG_TRACE("+-- Done <--+")
#define FAIL_DET 0x01
#define FAIL_DELTA 0x02
@@ -92,7 +102,9 @@
protected:
vector<vector<id_type> > combination;
- SpherePackingTriangulation triangulation;
+ #ifdef YADE_CGAL
+ SpherePackingTriangulation triangulation;
+ #endif
vector<tetra_porosity> tetra_porosities;
Criterion criterion;
@@ -111,7 +123,9 @@
void place_at_tetra_centers ();
void place_at_tetra_vertexes ();
void cancel_overlaps ();
- unsigned int iter_densify(unsigned int nb_check = 20);
+ #ifdef YADE_CGAL
+ unsigned int iter_densify(unsigned int nb_check = 20);
+ #endif
void repack_null_radii();
// some key functions
@@ -135,35 +149,44 @@
CellPartition partition;
list <id_type> bounds;
- bool verbose;
bool Must_Stop;
+ void init();
+
public:
+ typedef CellPartition::Cell Cell;
+ DECLARE_LOGGER;
+ // read mesh from file
+ SpherePadder(const std::string& fileName, std::string meshType="");
+ SpherePadder(){ init(); }
+ ~SpherePadder(){ if(mesh) delete mesh; }
bool meshIsPlugged;
-
- void ShutUp() { verbose = false; }
- void Speak() { verbose = true; }
void setRadiusRatio (double r, double rapp = 0.125);
+ Real getRadiusRatio(){ return ratio; };
void setRadiusRange (double min, double max);
+ py::tuple getRadiusRange(){ return py::make_tuple(rmin,rmax); }
void setMaxOverlapRate (double r) { max_overlap_rate = fabs(r); }
+ Real getMaxOverlapRate(){ return max_overlap_rate; }
void setVirtualRadiusFactor (double f) {virtual_radius_factor = fabs(f);}
+ Real getVirtualRadiusFactor(){ return virtual_radius_factor; }
void setMaxNumberOfSpheres (id_type max);
+ id_type getMaxNumberOfSpheres(){ return criterion.nb_spheres_max; }
void setMaxSolidFractioninProbe (double max, double x, double y,double z, double R);
+ py::tuple getMaxSolidFractionInProbe(){ return py::make_tuple(criterion.solid_fraction_max,criterion.x,criterion.y,criterion.z,criterion.R); }
vector<Sphere> & getSphereList() { return sphere;}
+ SpherePack getSpherePackObject();
TetraMesh * getMesh() { return mesh; }
id_type getNumberOfSpheres ();
double getMeanSolidFraction (double x, double y, double z, double R);
void plugTetraMesh (TetraMesh * mesh);
- void save_mgpost (const char* name);
+ void save_mgpost (std::string name);
void save_tri_mgpost (const char* name);
void save_Rxyz (const char* name);
- SpherePadder ();
-
// Check functions only for debug (very slow!!)
void detect_overlap ();
=== renamed file 'extra/SpherePadder/TetraMesh.cpp' => 'py/pack/SpherePadder/TetraMesh.cpp'
=== renamed file 'extra/SpherePadder/TetraMesh.hpp' => 'py/pack/SpherePadder/TetraMesh.hpp'
=== renamed file 'extra/SpherePadder/main.cpp' => 'py/pack/SpherePadder/main.cpp'
=== renamed file 'py/_packObb.cpp' => 'py/pack/_packObb.cpp'
=== renamed file 'py/_packPredicates.cpp' => 'py/pack/_packPredicates.cpp'
--- py/_packPredicates.cpp 2010-03-22 12:32:38 +0000
+++ py/pack/_packPredicates.cpp 2010-03-25 13:24:10 +0000
@@ -266,7 +266,7 @@
#ifdef YADE_GTS
extern "C" {
// HACK
-#include"3rd-party/pygts-0.3.1/pygts.h"
+#include"../3rd-party/pygts-0.3.1/pygts.h"
}
/* Helper function for inGtsSurface::aabb() */
=== renamed file 'extra/SpherePadder/SpherePadder_wrapper.cpp' => 'py/pack/_packSpherePadder.cpp'
--- extra/SpherePadder/SpherePadder_wrapper.cpp 2009-05-29 07:42:46 +0000
+++ py/pack/_packSpherePadder.cpp 2010-03-25 13:24:10 +0000
@@ -6,60 +6,45 @@
* GNU General Public License v2 or later. See file LICENSE for details. *
**************************************************************************/
-#include "SpherePadder.hpp"
-#include "TetraMesh.hpp"
-#include <boost/python.hpp>
-
-
-boost::python::list getSphereList(SpherePadder* SP)
-{
- boost::python::list l;
- vector <Sphere> & spheres = SP->getSphereList();
- double xtrans = SP->getMesh()->xtrans;
- double ytrans = SP->getMesh()->ytrans;
- double ztrans = SP->getMesh()->ztrans;
- for (unsigned int i = 0 ; i < spheres.size() ; ++i)
- {
- if (spheres[i].type == VIRTUAL || spheres[i].R <= 0.0) continue;
- l.append( boost::python::make_tuple(spheres[i].x+xtrans, spheres[i].y+ytrans, spheres[i].z+ztrans, spheres[i].R) );
- }
- return l;
-}
-
-
-BOOST_PYTHON_MODULE(packing){
- using namespace boost::python;
+#include"SpherePadder/SpherePadder.hpp"
+#include<yade/lib-pyutil/doc_opts.hpp>
+
+
+BOOST_PYTHON_MODULE(_packSpherePadder){
+
+ YADE_SET_DOCSTRING_OPTS;
- class_<TetraMesh>("TetraMesh")
- .def("read", &TetraMesh::read)
- .def("read_gmsh", &TetraMesh::read_gmsh)
- .def("read_inp", &TetraMesh::read_inp)
- ;
-
- class_<SpherePadder>("SpherePadder")
-
- .def("ShutUp", &SpherePadder::ShutUp)
- .def("Speak", &SpherePadder::Speak)
- .def("setRadiusRatio", &SpherePadder::setRadiusRatio)
- .def("setRadiusRange", &SpherePadder::setRadiusRange)
- .def("setMaxOverlapRate", &SpherePadder::setMaxOverlapRate)
- .def("setVirtualRadiusFactor", &SpherePadder::setVirtualRadiusFactor)
- .def("setMaxNumberOfSpheres", &SpherePadder::setMaxNumberOfSpheres)
- .def("setMaxSolidFractioninProbe", &SpherePadder::setMaxSolidFractioninProbe)
- .def("getNumberOfSpheres", &SpherePadder::getNumberOfSpheres)
- .def("getMeanSolidFraction", &SpherePadder::getMeanSolidFraction)
-
- .def("plugTetraMesh", &SpherePadder::plugTetraMesh)
+ // not wrapped directly; only pass filename to SpherePadder ctor
+ #if 0
+ class_<TetraMesh>("TetraMesh")
+ .def("read", &TetraMesh::read)
+ .def("read_gmsh", &TetraMesh::read_gmsh)
+ .def("read_inp", &TetraMesh::read_inp)
+ ;
+ #endif
+
+ py::class_<SpherePadder>("SpherePadder",py::init<std::string,std::string>((py::arg("fileName"),py::arg("meshType")=""),"Initialize using tetrahedral mesh stored in *fileName*. Type of file is determined by extension: .gmsh implies *meshType*='GMSH', .inp implies *meshType*='INP'. If the extension is different, specify *meshType* explicitly. Possible values are 'GMSH' and 'INP'."))
+
+ .add_property("radiusRatio", &SpherePadder::getRadiusRatio,&SpherePadder::setRadiusRatio)
+ .add_property("radiusRange", &SpherePadder::getRadiusRange,&SpherePadder::setRadiusRange)
+ .add_property("maxOverlapRate", &SpherePadder::getMaxOverlapRate,&SpherePadder::setMaxOverlapRate)
+ .add_property("virtualRadiusFactor", &SpherePadder::getVirtualRadiusFactor,&SpherePadder::setVirtualRadiusFactor)
+ .add_property("maxNumberOfSpheres", &SpherePadder::getMaxNumberOfSpheres,&SpherePadder::setMaxNumberOfSpheres)
+ .add_property("maxSolidFractioninProbe", &SpherePadder::getMaxSolidFractionInProbe,&SpherePadder::setMaxSolidFractioninProbe)
+ .add_property("numberOfSpheres", &SpherePadder::getNumberOfSpheres)
+ .def_readonly("meanSolidFraction",&SpherePadder::getMeanSolidFraction)
+
+ // .def("plugTetraMesh", &SpherePadder::plugTetraMesh) // takes pointer
.def("save_mgpost", &SpherePadder::save_mgpost)
- .def("save_Rxyz", &SpherePadder::save_Rxyz)
+ // .def("save_Rxyz", &SpherePadder::save_Rxyz) /// is asSpherePack.save(...) instead
.def("pad_5", &SpherePadder::pad_5)
.def("place_virtual_spheres", &SpherePadder::place_virtual_spheres)
.def("densify", &SpherePadder::densify)
.def("insert_sphere", &SpherePadder::insert_sphere)
+
+ .def("asSpherePack",&SpherePadder::getSpherePackObject);
;
-
- def("getSphereList", getSphereList);
}
=== renamed file 'py/_packSpheres.cpp' => 'py/pack/_packSpheres.cpp'
=== renamed file 'py/pack.py' => 'py/pack/pack.py'
--- py/pack.py 2010-03-09 14:20:36 +0000
+++ py/pack/pack.py 2010-03-25 13:24:10 +0000
@@ -45,6 +45,7 @@
# import SpherePack
from _packSpheres import *
from _packObb import *
+from _packSpherePadder import *
class inGtsSurface_py(Predicate):
=== modified file 'py/timing.py'
--- py/timing.py 2010-03-09 14:20:36 +0000
+++ py/timing.py 2010-03-25 13:24:10 +0000
@@ -51,7 +51,7 @@
def _engines_stats(engines,totalTime,level):
lines=0; hereLines=0
for e in engines:
- if not isinstance(e,Functor): print _formatLine(u'"'+e['label']+'"' if e['label'] else e.name,e.execTime,e.execCount,totalTime,level); lines+=1; hereLines+=1
+ if not isinstance(e,Functor): print _formatLine(u'"'+e.label+'"' if e.label else e.name,e.execTime,e.execCount,totalTime,level); lines+=1; hereLines+=1
if e.timingDeltas:
if isinstance(e,Functor):
print _formatLine(e.name,-1,-1,-1,level); lines+=1; hereLines+=1
=== modified file 'py/yadeWrapper/yadeWrapper.cpp'
--- py/yadeWrapper/yadeWrapper.cpp 2010-03-22 12:32:38 +0000
+++ py/yadeWrapper/yadeWrapper.cpp 2010-03-25 13:24:10 +0000
@@ -21,8 +21,6 @@
#include<boost/algorithm/string.hpp>
#include<boost/version.hpp>
-
-
#include<yade/lib-base/Logging.hpp>
#include<yade/lib-serialization-xml/XMLFormatManager.hpp>
#include<yade/lib-pyutil/gil.hpp>
@@ -45,7 +43,6 @@
#include<yade/pkg-common/InteractionPhysicsDispatcher.hpp>
#include<yade/pkg-common/LawDispatcher.hpp>
#include<yade/pkg-common/InteractionDispatchers.hpp>
-#include<yade/pkg-common/Aabb.hpp>
#include<yade/pkg-common/BoundFunctor.hpp>
#include<yade/pkg-common/InteractionGeometryFunctor.hpp>
@@ -61,8 +58,6 @@
#include<yade/extra/boost_python_len.hpp>
-
-
#ifdef YADE_LOG4CXX
log4cxx::LoggerPtr logger=log4cxx::Logger::getLogger("yade.python");
#endif