← Back to team overview

yade-dev team mailing list archive

[svn] r1779 - trunk/pkg/dem/PreProcessor

 

Author: eudoxos
Date: 2009-05-24 20:47:16 +0200 (Sun, 24 May 2009)
New Revision: 1779

Added:
   trunk/pkg/dem/PreProcessor/UniaxialStrainerGen.cpp
   trunk/pkg/dem/PreProcessor/UniaxialStrainerGen.hpp
Log:
2 forgotten files (separated from UniaxialStrainer before)


Added: trunk/pkg/dem/PreProcessor/UniaxialStrainerGen.cpp
===================================================================
--- trunk/pkg/dem/PreProcessor/UniaxialStrainerGen.cpp	2009-05-24 18:22:30 UTC (rev 1778)
+++ trunk/pkg/dem/PreProcessor/UniaxialStrainerGen.cpp	2009-05-24 18:47:16 UTC (rev 1779)
@@ -0,0 +1,127 @@
+// 2008 © Václav Šmilauer <eudoxos@xxxxxxxx> 
+
+#include"UniaxialStrainerGen.hpp"
+
+#include<yade/pkg-dem/ConcretePM.hpp>
+
+#include<yade/pkg-common/RigidBodyParameters.hpp>
+#include<yade/pkg-common/InteractionPhysicsEngineUnit.hpp>
+#include<yade/pkg-common/PhysicalActionContainerReseter.hpp>
+#include<yade/pkg-common/BoundingVolumeMetaEngine.hpp>
+#include<yade/pkg-common/AABB.hpp>
+#include<yade/pkg-common/InteractingSphere2AABB.hpp>
+#include<yade/pkg-common/MetaInteractingGeometry.hpp>
+#include<yade/pkg-common/MetaInteractingGeometry2AABB.hpp>
+#include<yade/pkg-common/InteractionGeometryMetaEngine.hpp>
+#include<yade/pkg-common/InteractionPhysicsMetaEngine.hpp>
+#include<yade/pkg-common/PhysicalActionApplier.hpp>
+#include<yade/pkg-common/PhysicalParametersMetaEngine.hpp>
+#include<yade/pkg-common/PersistentSAPCollider.hpp>
+#include<yade/pkg-common/ConstitutiveLawDispatcher.hpp>
+#include<yade/pkg-dem/NewtonsDampedLaw.hpp>
+#include<yade/pkg-dem/BodyMacroParameters.hpp>
+#include<yade/pkg-dem/Dem3DofGeom_SphereSphere.hpp>
+
+CREATE_LOGGER(UniaxialStrainerGen);
+
+bool UniaxialStrainerGen::generate(){
+	message="";
+	rootBody=Shop::rootBody();
+	//Shop::rootBodyActors(rootBody);
+	createEngines();
+	shared_ptr<UniaxialStrainer> strainer(new UniaxialStrainer);
+	rootBody->engines.push_back(strainer); // updating params later
+	strainer->strainRate=strainRate;
+	strainer->axis=axis;
+	strainer->limitStrain=limitStrain;
+	
+	// load spheres
+	Vector3r minXYZ,maxXYZ;
+	typedef vector<pair<Vector3r,Real> > vecVecReal;
+
+	vecVecReal spheres;
+	if(spheresFile.empty()){ 
+		LOG_INFO("spheresFile empty, loading hardwired Shop::smallSdecXyzData (examples/small.sdec.xyz).");
+		spheres=Shop::loadSpheresSmallSdecXyz(minXYZ,maxXYZ);
+	}
+	else spheres=Shop::loadSpheresFromFile(spheresFile,minXYZ,maxXYZ);
+
+
+	TRVAR2(minXYZ,maxXYZ);
+	// get spheres that are "close enough" to the strained ends
+	for(vecVecReal::iterator I=spheres.begin(); I!=spheres.end(); I++){
+		Vector3r C=I->first;
+		Real r=I->second;
+		shared_ptr<Body> S=Shop::sphere(C,r);
+
+		// replace BodyMacroParameters by CpmMat
+		shared_ptr<BodyMacroParameters> bmp=YADE_PTR_CAST<BodyMacroParameters>(S->physicalParameters);
+		shared_ptr<CpmMat> bpp(new CpmMat);
+		#define _CP(attr) bpp->attr=bmp->attr;
+		_CP(acceleration); _CP(angularVelocity); _CP(blockedDOFs); _CP(frictionAngle); _CP(inertia); _CP(mass); _CP(poisson); _CP(refSe3); _CP(se3); _CP(young); _CP(velocity);
+		#undef _CP
+		S->physicalParameters=bpp;
+
+		body_id_t sId=rootBody->bodies->insert(S);
+
+		Real distFactor=1.2;
+		if (C[axis]-distFactor*r<minXYZ[axis]) {
+			strainer->negIds.push_back(sId);
+			strainer->negCoords.push_back(C[axis]);
+			LOG_DEBUG("NEG inserted #"<<sId<<" with C[axis]="<<C[axis]);
+		}
+		if (C[axis]+distFactor*r>maxXYZ[axis]) {
+			strainer->posIds.push_back(sId);
+			strainer->posCoords.push_back(C[axis]);
+			LOG_DEBUG("POS inserted #"<<sId<<" with C[axis]="<<C[axis]);
+		}
+	}
+
+	return true;
+}
+
+
+
+void UniaxialStrainerGen::createEngines(){
+	rootBody->initializers.clear();
+
+	shared_ptr<BoundingVolumeMetaEngine> boundingVolumeDispatcher	= shared_ptr<BoundingVolumeMetaEngine>(new BoundingVolumeMetaEngine);
+		boundingVolumeDispatcher->add(new InteractingSphere2AABB);
+		boundingVolumeDispatcher->add(new MetaInteractingGeometry2AABB);
+		rootBody->initializers.push_back(boundingVolumeDispatcher);
+
+	rootBody->engines.clear();
+
+	rootBody->engines.push_back(shared_ptr<Engine>(new PhysicalActionContainerReseter));
+	rootBody->engines.push_back(boundingVolumeDispatcher);
+
+	shared_ptr<PersistentSAPCollider> collider(new PersistentSAPCollider);
+		collider->haveDistantTransient=true;
+		rootBody->engines.push_back(collider);
+
+	shared_ptr<InteractionGeometryMetaEngine> igeomDispatcher(new InteractionGeometryMetaEngine);
+		igeomDispatcher->add(shared_ptr<ef2_Sphere_Sphere_Dem3DofGeom>(new ef2_Sphere_Sphere_Dem3DofGeom));
+		rootBody->engines.push_back(igeomDispatcher);
+
+	shared_ptr<InteractionPhysicsMetaEngine> iphysDispatcher(new InteractionPhysicsMetaEngine);
+		shared_ptr<Ip2_CpmMat_CpmMat_CpmPhys> bmc(new Ip2_CpmMat_CpmMat_CpmPhys);
+		bmc->cohesiveThresholdIter=cohesiveThresholdIter;
+		bmc->cohesiveThresholdIter=-1; bmc->G_over_E=1;bmc->sigmaT=3e9; bmc->neverDamage=true; bmc->epsCrackOnset=1e-4; bmc->relDuctility=5;
+		iphysDispatcher->add(bmc);
+	rootBody->engines.push_back(iphysDispatcher);
+
+	shared_ptr<ConstitutiveLawDispatcher> clDisp(new ConstitutiveLawDispatcher);
+		clDisp->add(shared_ptr<ConstitutiveLaw>(new Law2_Dem3DofGeom_CpmPhys_Cpm));
+	rootBody->engines.push_back(clDisp);
+
+	shared_ptr<NewtonsDampedLaw> newton(new NewtonsDampedLaw);
+		newton->damping=damping;
+	rootBody->engines.push_back(newton);
+
+	rootBody->engines.push_back(shared_ptr<CpmPhysDamageColorizer>(new CpmPhysDamageColorizer));
+
+}
+
+
+
+

Added: trunk/pkg/dem/PreProcessor/UniaxialStrainerGen.hpp
===================================================================
--- trunk/pkg/dem/PreProcessor/UniaxialStrainerGen.hpp	2009-05-24 18:22:30 UTC (rev 1778)
+++ trunk/pkg/dem/PreProcessor/UniaxialStrainerGen.hpp	2009-05-24 18:47:16 UTC (rev 1779)
@@ -0,0 +1,38 @@
+// 2008 © Václav Šmilauer <eudoxos@xxxxxxxx> 
+
+#pragma once
+#include<yade/extra/Shop.hpp>
+#include<yade/core/FileGenerator.hpp>
+#include<yade/pkg-dem/UniaxialStrainer.hpp>
+
+/*
+	Class for demonstrating the use of UniaxialStrainer.
+	It is better to use UniaxialStrainer from python, since that way
+	stresses can be plot easily etc.
+*/
+class UniaxialStrainerGen: public FileGenerator {
+	private:
+		void createEngines();
+	public:
+		UniaxialStrainerGen(){ axis=1; limitStrain=0; damping=0.2;cohesiveThresholdIter=10;};
+		~UniaxialStrainerGen (){};
+		bool generate();
+		string spheresFile;
+		Real strainRate, limitStrain, damping;
+		int axis;
+		long cohesiveThresholdIter;
+	protected :
+		void registerAttributes(){
+			FileGenerator::registerAttributes();
+			REGISTER_ATTRIBUTE(spheresFile);
+			REGISTER_ATTRIBUTE(axis);
+			REGISTER_ATTRIBUTE(strainRate);
+			REGISTER_ATTRIBUTE(limitStrain);
+			REGISTER_ATTRIBUTE(damping);
+			REGISTER_ATTRIBUTE(cohesiveThresholdIter);
+		}
+	REGISTER_CLASS_AND_BASE(UniaxialStrainerGen,FileGenerator);
+	DECLARE_LOGGER;
+};
+REGISTER_SERIALIZABLE(UniaxialStrainerGen);
+