← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2473: 1. Link to the standard libstdc++.so.6 (which is instaleld everywhere) instead of libstdc++.so, w...

 

------------------------------------------------------------
revno: 2473
committer: Václav Šmilauer <eu@xxxxxxxx>
branch nick: yade
timestamp: Tue 2010-10-12 13:47:16 +0200
message:
  1. Link to the standard libstdc++.so.6 (which is instaleld everywhere) instead of libstdc++.so, which is only in the devel package of gcc
  2. Full support for compilation with clang (packaged for lucid and maverick now), as explained at https://www.yade-dem.org/wiki/Compilation_with_LLVM/clang#Building_yade (openmp and optimizations do not work)
  3. Add function to ScGeom to compute incident velocity from python.
modified:
  SConstruct
  gui/SConscript
  pkg/dem/DataClass/IGeom/ScGeom.cpp
  pkg/dem/DataClass/IGeom/ScGeom.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 'SConstruct'
--- SConstruct	2010-10-11 16:28:49 +0000
+++ SConstruct	2010-10-12 11:47:16 +0000
@@ -125,7 +125,8 @@
 	('realVersion','Revision (usually bzr revision); guessed automatically unless specified',None),
 	('CPPPATH', 'Additional paths for the C preprocessor (colon-separated)','/usr/include/vtk-5.0:/usr/include/vtk-5.2:/usr/include/vtk-5.4:/usr/include/eigen2:/usr/include/vtk'), # hardy has vtk-5.0
 	('LIBPATH','Additional paths for the linker (colon-separated)',None),
-	('libstdcxx','Specify libstdc++ location by hand (opened dynamically at startup); only needed when compiling with clang',None),
+	('libstdcxx','Specify libstdc++ location by hand (opened dynamically at startup), usually not needed',None),
+	('QT4CXX','Specify a different compiler for files including qt4; this is necessary for older qt version (<=4.7) which don\'t compile with clang',None),
 	('QT4DIR','Directory where Qt4 is installed','/usr/share/qt4'),
 	('PATH','Path (not imported automatically from the shell) (colon-separated)',None),
 	('CXX','The c++ compiler','g++'),
@@ -262,8 +263,11 @@
 		l=context.env['libstdcxx']
 		context.Result(l+' (specified by the user)')
 		return l
-	ret=os.popen(context.env['CXX']+' -print-file-name=libstdc++.so').readlines()[0][:-1]
-	context.env['libstdcxx']=ret
+	ret=os.popen(context.env['CXX']+' -print-file-name=libstdc++.so.6').readlines()[0][:-1]
+	if ret[0]!='/':
+		context.Result('Relative path "%s" was given by compiler %s, must specify libstdcxx=.. explicitly.'%(ret,context.env['CXX']))
+		Exit(1)
+	context.env['libstdcxx']=os.path.abspath(ret) # removes .. in g++ path
 	context.Result(ret)
 	return ret
 
@@ -369,7 +373,6 @@
 			elif conf.CheckLibWithHeader(['libQGLViewer'],'QGLViewer/qglviewer.h','c++','QGLViewer();',autoadd=1):
 				env['QGLVIEWER_LIB']='libQGLViewer'
 			else: featureNotOK('qt4','Building with Qt4 implies the QGLViewer library installed (package libqglviewer-qt4-dev package in debian/ubuntu, libQGLViewer in RPM-based distributions)')
-
 	if 'vtk' in env['features']:
 		ok=conf.CheckLibWithHeader(['vtkCommon'],'vtkInstantiator.h','c++','vtkInstantiator::New();',autoadd=1)
 		env.Append(LIBS='vtkHybrid')
@@ -465,6 +468,12 @@
 if env['PGO']=='gen': env.Append(CXXFLAGS=['-fprofile-generate'],LINKFLAGS=['-fprofile-generate'])
 if env['PGO']=='use': env.Append(CXXFLAGS=['-fprofile-use'],LINKFLAGS=['-fprofile-use'])
 
+if 'clang' in env['CXX']:
+	print 'Probably using clang to compile, adding -Wno-unused-variable -Wno-mismatched-tags -Wno-constant-logical-operand -Qunused-arguments'
+	env.Append(CXXFLAGS=['-Wno-unused-variable','-Wno-mismatched-tags','-Wno-constant-logical-operand','-Qunused-arguments'])
+	if 'openmp' in env['features']: print 'WARNING: building with clang and OpenMP, expect errors!'
+
+
 ### LINKER
 ## libs for all plugins
 env.Append(LIBS=[],SHLINKFLAGS=['-rdynamic'])

=== modified file 'gui/SConscript'
--- gui/SConscript	2010-10-11 16:28:49 +0000
+++ gui/SConscript	2010-10-12 11:47:16 +0000
@@ -9,7 +9,7 @@
 		env.File('qt4/SerializableEditor.py'),
 		env.File('qt4/Inspector.py'),
 		env.File('qt4/__init__.py'),
-		env.SharedLibrary('_GLViewer',['qt4/GLViewer.cpp','qt4/_GLViewer.cpp','qt4/OpenGLManager.cpp'],SHLIBPREFIX='',LIBS=env['LIBS']+[env['QGLVIEWER_LIB']]+linkPlugins(['PeriodicEngines']),RPATH=env['RPATH']+[env.Literal('\\$$ORIGIN/../../../gui')])
+		env.SharedLibrary('_GLViewer',['qt4/GLViewer.cpp','qt4/_GLViewer.cpp','qt4/OpenGLManager.cpp'],SHLIBPREFIX='',LIBS=env['LIBS']+[env['QGLVIEWER_LIB']]+linkPlugins(['PeriodicEngines']),RPATH=env['RPATH']+[env.Literal('\\$$ORIGIN/../../../gui')],CXX=env['QT4CXX'] if env['QT4CXX'] else env['CXX'],CXXFLAGS=[f for f in env['CXXFLAGS'] if not f.startswith('-Q')])
 	])
 	env.Command('qt4/img_rc.py','qt4/img.qrc','pyrcc4 -o $buildDir/gui/qt4/img_rc.py gui/qt4/img.qrc')
 	env.Command('qt4/ui_controller.py','qt4/controller.ui','pyuic4 -o $buildDir/gui/qt4/ui_controller.py gui/qt4/controller.ui')

=== modified file 'pkg/dem/DataClass/IGeom/ScGeom.cpp'
--- pkg/dem/DataClass/IGeom/ScGeom.cpp	2010-07-18 19:21:08 +0000
+++ pkg/dem/DataClass/IGeom/ScGeom.cpp	2010-10-12 11:47:16 +0000
@@ -73,3 +73,12 @@
 	//Just pass null shift to the periodic version
 	return getIncidentVel(rbp1,rbp2,dt,Vector3r::Zero(),avoidGranularRatcheting);
 }
+
+Vector3r ScGeom::getIncidentVel_py(shared_ptr<Interaction> i, bool avoidGranularRatcheting){
+	if(i->geom.get()!=this) throw invalid_argument("ScGeom object is not the same as Interaction.geom.");
+	Scene* scene=Omega::instance().getScene().get();
+	return getIncidentVel(Body::byId(i->getId1(),scene)->state.get(),Body::byId(i->getId2(),scene)->state.get(),
+		scene->dt,
+		scene->isPeriodic ? Vector3r(scene->cell->velGrad*scene->cell->Hsize*i->cellDist.cast<Real>()) : Vector3r::Zero(),
+		avoidGranularRatcheting);
+}

=== modified file 'pkg/dem/DataClass/IGeom/ScGeom.hpp'
--- pkg/dem/DataClass/IGeom/ScGeom.hpp	2010-09-30 18:00:41 +0000
+++ pkg/dem/DataClass/IGeom/ScGeom.hpp	2010-10-12 11:47:16 +0000
@@ -37,6 +37,9 @@
 		Vector3r getIncidentVel(const State* rbp1, const State* rbp2, Real dt, const Vector3r& shiftVel, bool avoidGranularRatcheting=true);
 		// Implement another version of getIncidentVel which does not handle periodicity.
 		Vector3r getIncidentVel(const State* rbp1, const State* rbp2, Real dt, bool avoidGranularRatcheting=true);
+		
+		// convenience version to be called from python
+		Vector3r getIncidentVel_py(shared_ptr<Interaction> i, bool avoidGranularRatcheting); 
 	
 		YADE_CLASS_BASE_DOC_ATTRS_INIT_CTOR_PY(ScGeom,GenericSpheresContact,"Class representing :yref:`geometry<IGeom>` of two :yref:`bodies<Body>` in contact. The contact has 3 DOFs (normal and 2×shear) and uses incremental algorithm for updating shear. (For shear formulated in total displacements and rotations, see :yref:`Dem3DofGeom` and related classes).\n\nWe use symbols $\\vec{x}$, $\\vec{v}$, $\\vec{\\omega}$ respectively for position, linear and angular velocities (all in global coordinates) and $r$ for particles radii; subscripted with 1 or 2 to distinguish 2 spheres in contact. Then we compute unit contact normal\n\n.. math::\n\n\t\\vec{n}=\\frac{\\vec{x}_2-\\vec{x}_1}{||\\vec{x}_2-\\vec{x}_1||}\n\nRelative velocity of spheres is then\n\n.. math::\n\n\t\\vec{v}_{12}=(\\vec{v}_2+\\vec{\\omega}_2\\times(-r_2\\vec{n}))-(\\vec{v}_1+\\vec{\\omega}_1\\times(r_1\\vec{n}))\n\nand its shear component\n\n.. math::\n\n\t\\Delta\\vec{v}_{12}^s=\\vec{v}_{12}-(\\vec{n}\\cdot\\vec{v}_{12})\\vec{n}.\n\nTangential displacement increment over last step then reads\n\n.. math::\n\n\t\\vec{x}_{12}^s=\\Delta t \\vec{v}_{12}^s.",
 		((Real,penetrationDepth,NaN,(Attr::noSave|Attr::readonly),"Penetration distance of spheres (positive if overlapping)"))
@@ -44,6 +47,7 @@
 		,
 		/* extra initializers */ ((radius1,GenericSpheresContact::refR1)) ((radius2,GenericSpheresContact::refR2)),
 		/* ctor */ createIndex(); twist_axis=orthonormal_axis=Vector3r::Zero();,
+		/* py */ .def("incidentVel",&ScGeom::getIncidentVel_py,(python::arg("i"),python::arg("avoidGranularRatcheting")=true),"Return incident velocity of the interaction.")
 	);
 	REGISTER_CLASS_INDEX(ScGeom,GenericSpheresContact);
 };