yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #07850
[Branch ~yade-dev/yade/trunk] Rev 2913: rotation of facets taken into account in yade.export.VTKExporter
------------------------------------------------------------
revno: 2913
committer: Jan Stransky <honzik.stransky@xxxxxxxxx>
branch nick: yade
timestamp: Tue 2011-08-30 20:52:11 +0200
message:
rotation of facets taken into account in yade.export.VTKExporter
modified:
pkg/dem/ConcretePM.cpp
pkg/dem/ConcretePM.hpp
py/export.py
py/ymport.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 'pkg/dem/ConcretePM.cpp'
--- pkg/dem/ConcretePM.cpp 2011-08-29 18:23:23 +0000
+++ pkg/dem/ConcretePM.cpp 2011-08-30 18:52:11 +0000
@@ -159,6 +159,7 @@
BC->crossSection=Mathr::PI*pow(minRad,2);
BC->kn=BC->crossSection*BC->E/contGeom->refLength;
BC->ks=BC->crossSection*BC->G/contGeom->refLength;
+ BC->epsFracture = isnan(BC->crackOpening)? BC->epsCrackOnset*BC->relDuctility : BC->crackOpening/contGeom->refLength;
}
// shorthands
@@ -175,7 +176,8 @@
const Real& epsCrackOnset(BC->epsCrackOnset);
Real& relResidualStrength(BC->relResidualStrength);
const Real& crackOpening(BC->crackOpening);
- const Real& epsF(BC->epsCrackOnset*BC->relDuctility);
+ const Real& relDuctility(BC->relDuctility);
+ const Real& epsFracture(BC->epsFracture);
const int& damLaw(BC->damLaw);
const bool& neverDamage(BC->neverDamage);
Real& omega(BC->omega);
@@ -228,7 +230,6 @@
// very simplified version of the constitutive law
kappaD=max(max(0.,epsN),kappaD); // internal variable, max positive strain (non-decreasing)
//Real epsFracture = crackOpening/contGeom->refLength;
- Real epsFracture = isnan(epsF)? crackOpening/contGeom->refLength : epsF;
omega=isCohesive?funcG(kappaD,epsCrackOnset,epsFracture,neverDamage,damLaw):1.; // damage variable (non-decreasing, as funcG is also non-decreasing)
sigmaN=(1-(epsN>0?omega:0))*E*epsN; // damage taken in account in tension only
sigmaT=G*epsT; // trial stress
@@ -243,7 +244,7 @@
#endif
sigmaN-=BC->isoPrestress;
- NNAN(kappaD); NNAN(epsCrackOnset); NNAN(crackOpening); NNAN(omega);
+ NNAN(kappaD); NNAN(epsFracture); NNAN(omega);
NNAN(sigmaN); NNANV(sigmaT); NNAN(crossSection);
// handle broken contacts
=== modified file 'pkg/dem/ConcretePM.hpp'
--- pkg/dem/ConcretePM.hpp 2011-08-29 18:23:23 +0000
+++ pkg/dem/ConcretePM.hpp 2011-08-30 18:52:11 +0000
@@ -126,8 +126,9 @@
((Real,undamagedCohesion,NaN,,"virgin material cohesion [Pa]"))
((Real,crossSection,NaN,,"equivalent cross-section associated with this contact [m²]"))
((Real,epsCrackOnset,NaN,,"strain at which the material starts to behave non-linearly"))
- ((Real,crackOpening,NaN,,"Crack opening when the crack is fully broken in tension. [m]"))
- ((Real,relDuctility,NaN,,"Deprecated"))
+ ((Real,crackOpening,NaN,,"Crack opening (extansion of the bond) when the bond is fully broken in tension. [m]"))
+ ((Real,relDuctility,NaN,,"Deprecated, use :yref:`CpmMat::crackOpening` instead"))
+ ((Real,epsFracture,NaN,,"strain at which the bond is fully broken [-]"))
((Real,dmgTau,-1,,"characteristic time for damage (if non-positive, the law without rate-dependence is used)"))
((Real,dmgRateExp,0,,"exponent in the rate-dependent damage evolution"))
((Real,dmgStrain,0,,"damage strain (at previous or current step)"))
=== modified file 'py/export.py'
--- py/export.py 2011-08-29 18:23:23 +0000
+++ py/export.py 2011-08-30 18:52:11 +0000
@@ -185,7 +185,7 @@
class VTKExporter:
- """Class for exporting data to VTK Simple Legacy File (for example if, for some reasin, you are not able to use VTKRecorder). Export of spheres and facets is supported.
+ """Class for exporting data to VTK Simple Legacy File (for example if, for some reason, you are not able to use VTKRecorder). Export of spheres and facets is supported.
USAGE:
create object vtkExporter = VTKExporter('baseFileName'),
@@ -199,8 +199,9 @@
def exportSpheres(self,ids='all',what=[],comment="comment",numLabel=None):
"""
exports spheres (positions and radius) and defined properties.
-:parameters:
- `ids`: list | "all"
+
+ :parameters:
+ `ids`: [int] | "all"
if "all", then export all spheres, otherwise only spheres from integer list
`what`: [tuple(2)]
what other than then position and radius export. parameter is list of couple (name,command). Name is string under which it is save to vtk, command is string to evaluate. Node that the bodies are labeled as b in this function. Scalar, vector and tensor variables are supported. For example, to export velocity (with name particleVelocity) and the distance form point (0,0,0) (named as dist) you should write: ... what=[('particleVelocity','b.state.vel'),('dist','b.state.pos.norm()', ...
@@ -252,6 +253,7 @@
def exportFacets(self,ids='all',what=[],comment="comment",numLabel=None):
"""
exports facets (positions) and defined properties.
+
:parameters:
`ids`: list | "all"
if "all", then export all spheres, otherwise only spheres from integer list
@@ -278,9 +280,12 @@
outFile = open(self.baseName+'-facets-%04d'%self.facetsSnapCount+'.vtk', 'w')
outFile.write("# vtk DataFile Version 3.0.\n%s\nASCII\n\nDATASET POLYDATA\nPOINTS %d double\n"%(comment,3*n))
for b in bodies:
- pt1 = b.state.pos + b.shape.vertices[0]
- pt2 = b.state.pos + b.shape.vertices[1]
- pt3 = b.state.pos + b.shape.vertices[2]
+ p = b.state.pos
+ o = b.state.ori
+ s = b.shape
+ pt1 = p + o*s.vertices[0]
+ pt2 = p + o*s.vertices[1]
+ pt3 = p + o*s.vertices[2]
outFile.write("%g %g %g\n"%(pt1[0],pt1[1],pt1[2]))
outFile.write("%g %g %g\n"%(pt2[0],pt2[1],pt2[2]))
outFile.write("%g %g %g\n"%(pt3[0],pt3[1],pt3[2]))
=== modified file 'py/ymport.py'
--- py/ymport.py 2011-08-27 18:10:30 +0000
+++ py/ymport.py 2011-08-30 18:52:11 +0000
@@ -244,62 +244,10 @@
return ret
-class UNVReader:
- # class used in ymport.unv function
- # reads and evaluate given unv file and extracts all triangles
- # can be extended to read tetrahedrons as well
- def __init__(self,fileName,shift=(0,0,0),scale=1.0):
- self.shift = shift
- self.scale = scale
- self.unvFile = open(fileName,'r')
- self.flag = 0
- self.line = self.unvFile.readline()
- self.lineSplit = self.line.split()
- self.vertices = []
- self.verticesTris = []
- self.read()
- def readLine(self):
- self.line = self.unvFile.readline()
- self.lineSplit = self.line.split()
- def read(self):
- while self.line:
- self.evalLine()
- self.line = self.unvFile.readline()
- self.unvFile.close()
- def evalLine(self):
- self.lineSplit = self.line.split()
- if len(self.lineSplit) <= 1: # eval special unv format
- if self.lineSplit[0] == '-1': pass
- elif self.lineSplit[0] == '2411': self.flag = 1; # nodes
- elif self.lineSplit[0] == '2412': self.flag = 2; # edges (lines)
- else: self.flag = 4; # volume elements or other, not interesting for us
- elif self.flag == 1: self.evalVertices()
- elif self.flag == 2: self.evalEdge()
- elif self.flag == 3: self.evalFacet()
- #elif self.flag == 4: self.evalGroup()
- def evalVertices(self):
- self.readLine()
- self.vertices.append((
- self.shift[0]+self.scale*float(self.lineSplit[0]),
- self.shift[1]+self.scale*float(self.lineSplit[1]),
- self.shift[2]+self.scale*float(self.lineSplit[2])))
- def evalEdge(self):
- if self.lineSplit[1]=='41': self.flag = 3; self.evalFacet()
- else: self.readLine(); self.readLine()
- def evalFacet(self):
- if self.lineSplit[1]=='41': # triangle
- self.readLine()
- self.verticesTris.append([
- self.vertices[int(self.lineSplit[0])-1],
- self.vertices[int(self.lineSplit[1])-1],
- self.vertices[int(self.lineSplit[2])-1]])
- else: # is not triangle
- self.readLine()
- self.flag = 4
- # can be added function to handle tetrahedrons
def unv(fileName,shift=(0,0,0),scale=1.0,**kw):
""" Import geometry from unv file, return list of created facets.
+
:Parameters:
`fileName`: string
name of unv file
@@ -310,10 +258,65 @@
`**kw`: (unused keyword arguments)
is passed to :yref:`yade.utils.facet`
- unv files are mainly used for FEM analyses (are used by OOFEM and Abakus TODO), but triangular elements can be imported as facets.
- These files cen be created e.g. with open-source free software Salome (salome-platform.org TODO)
+ unv files are mainly used for FEM analyses (are used by `OOFEM <http://www.oofem.org/>` and `Abakus <http://www.simulia.com/products/abaqus_fea.html>`), but triangular elements can be imported as facets.
+ These files cen be created e.g. with open-source free software `Salome <salome-platform.org>`.
Example: :ysrc:`scripts/test/unvRead.py`."""
+
+ class UNVReader:
+ # class used in ymport.unv function
+ # reads and evaluate given unv file and extracts all triangles
+ # can be extended to read tetrahedrons as well
+ def __init__(self,fileName,shift=(0,0,0),scale=1.0):
+ self.shift = shift
+ self.scale = scale
+ self.unvFile = open(fileName,'r')
+ self.flag = 0
+ self.line = self.unvFile.readline()
+ self.lineSplit = self.line.split()
+ self.vertices = []
+ self.verticesTris = []
+ self.read()
+ def readLine(self):
+ self.line = self.unvFile.readline()
+ self.lineSplit = self.line.split()
+ def read(self):
+ while self.line:
+ self.evalLine()
+ self.line = self.unvFile.readline()
+ self.unvFile.close()
+ def evalLine(self):
+ self.lineSplit = self.line.split()
+ if len(self.lineSplit) <= 1: # eval special unv format
+ if self.lineSplit[0] == '-1': pass
+ elif self.lineSplit[0] == '2411': self.flag = 1; # nodes
+ elif self.lineSplit[0] == '2412': self.flag = 2; # edges (lines)
+ else: self.flag = 4; # volume elements or other, not interesting for us
+ elif self.flag == 1: self.evalVertices()
+ elif self.flag == 2: self.evalEdge()
+ elif self.flag == 3: self.evalFacet()
+ #elif self.flag == 4: self.evalGroup()
+ def evalVertices(self):
+ self.readLine()
+ self.vertices.append((
+ self.shift[0]+self.scale*float(self.lineSplit[0]),
+ self.shift[1]+self.scale*float(self.lineSplit[1]),
+ self.shift[2]+self.scale*float(self.lineSplit[2])))
+ def evalEdge(self):
+ if self.lineSplit[1]=='41': self.flag = 3; self.evalFacet()
+ else: self.readLine(); self.readLine()
+ def evalFacet(self):
+ if self.lineSplit[1]=='41': # triangle
+ self.readLine()
+ self.verticesTris.append([
+ self.vertices[int(self.lineSplit[0])-1],
+ self.vertices[int(self.lineSplit[1])-1],
+ self.vertices[int(self.lineSplit[2])-1]])
+ else: # is not triangle
+ self.readLine()
+ self.flag = 4
+ # can be added function to handle tetrahedrons
+
unvReader = UNVReader(fileName,shift,scale,**kw)
return [utils.facet(tri,**kw) for tri in unvReader.verticesTris]