Statistiques
| Révision :

root / examples / AFM-plane.py @ 1

Historique | Voir | Annoter | Télécharger (3,28 ko)

1
import Sofa
2

    
3
poissonRatio = 0.49
4
youngModulus = 100
5
pressure = 5
6

    
7
indentorRadius = 0.3
8

    
9
def createScene(node): 
10
    
11
    print 'Creation of Sofa SceneGraph'    
12
    
13
    node.gravity = [0,0,0]
14

    
15
    node.createObject('RequiredPlugin', pluginName="Flexible") 
16
    node.createObject('RequiredPlugin', pluginName="AFM_plane")
17

    
18
    node.createObject('VisualStyle', displayFlags = 'showVisual hideBehavior showCollisionModels')
19
    node.createObject('DefaultPipeline', name="DefaultCollisionPipeline",  verbose="0",  draw="0",  depth="6")
20
    node.createObject('BruteForceDetection', name="Detection")
21
    node.createObject('MinProximityIntersection', name="Proximity",  alarmDistance="0.05",  contactDistance="0.0")
22
    node.createObject('MyDefaultContactManager', name="Response",  response="default", responseParams="")
23
    node.createObject('TreeCollisionGroupManager', name="Group")
24

    
25
    node.createObject('CGLinearSolver', template="GraphScattered",iterations=500,threshold=1e-10,tolerance=1e-10)
26
    node.createObject('EulerImplicitSolver', rayleighStiffness=0.5,rayleighMass=0.5)
27

    
28
    node.createObject('GridMeshCreator', name='Grid', resolution="10 10", triangulate=1)
29
    node.createObject('MeshTopology', name='Topology',src="@Grid")
30
    node.createObject('MechanicalObject', name='DOFs', template="Vec3d")    
31
    node.createObject('UniformMass',name='mass', template='Vec3d')
32
    node.createObject('FixedConstraint',template="Vec3d", indices="0 9 90 99" )
33

    
34
    ## Pressure
35
    node.createObject("SurfacePressureForceField",  pressure=pressure)
36

    
37
    ## Deformation, Stress and Strain
38
    node.createObject('BarycentricShapeFunction', template="ShapeFunctiond")
39
    deformation = node.createChild("deformation")
40
    deformation.createObject('TopologyGaussPointSampler',name='sampler', inPosition='@../Topology.position' , showSamples="false", method="0", order="1" )
41
    deformation.createObject('MechanicalObject', name='deform', template='F321')
42
    deformation.createObject('LinearMapping', template='Vec3d,F321')
43
    stressStrain = deformation.createChild('stressStrain')
44
    stressStrain.createObject('MechanicalObject', name='Strain',template='E321')
45
    stressStrain.createObject('CorotationalStrainMapping', template="F321,E321")
46
    stressStrain.createObject('HookeForceField', template="E321", youngModulus=youngModulus,poissonRatio=poissonRatio, viscosity=0  )
47

    
48
    ## Collision
49
    node.createObject('TriangleModel',contactStiffness=1000,group=0)
50
    node.createObject('LineModel',contactStiffness=1000,group=0)
51
    node.createObject('PointModel',contactStiffness=1000,group=0)
52
    Visu = node.createChild('Visu')
53
    Visu.createObject('OglModel')
54
    Visu.createObject('IdentityMapping', template='Vec3d,ExtVec3f')
55

    
56
    ## indentor
57
    indentor = node.createChild('indentor')
58
    indentor.createObject('MechanicalObject',name='indentor', position="0.5 0.5 2")
59
    indentor.createObject('UniformMass')
60
    indentor.createObject('ConstantForceField', points=0, force="0 0 -1")
61
    indentor.createObject('TSphereModel', radius= indentorRadius, ContactStiffness=1000, group=1) 
62
    indentor.createObject('ProjectToLineConstraint',endTime='-1', indices=0, origin="0.5 0.5 2", direction="0 0 1") 
63
    indentor.createObject('PointConstraint', endTime=3, indices=0)