Statistiques
| Révision :

root / examples / plane.py @ 1

Historique | Voir | Annoter | Télécharger (3,19 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
    
17
    node.createObject('VisualStyle', displayFlags = 'showVisual hideBehavior showCollisionModels')
18
    node.createObject('DefaultPipeline', name="DefaultCollisionPipeline",  verbose="0",  draw="0",  depth="6")
19
    node.createObject('BruteForceDetection', name="Detection")
20
    node.createObject('MinProximityIntersection', name="Proximity",  alarmDistance="0.1",  contactDistance="0.0")
21
    node.createObject('DefaultContactManager', name="Response",  response="default", responseParams="")
22
    node.createObject('TreeCollisionGroupManager', name="Group")
23

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

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

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

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

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

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