-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathSurfacePressureEquality.py
More file actions
69 lines (58 loc) · 3.55 KB
/
SurfacePressureEquality.py
File metadata and controls
69 lines (58 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from PythonScripts.EqController import Controller
import ConstantsAccordeon as Const
import os
MeshesPath = os.path.dirname(os.path.abspath(__file__)) + '/GeneratedMeshes/'
def createScene(rootNode):
rootNode.addObject('RequiredPlugin', pluginName='SofaPython3 SoftRobots SoftRobots.Inverse')
rootNode.addObject('VisualStyle',
displayFlags='hideWireframe showBehaviorModels hideCollisionModels '
'hideBoundingCollisionModels showForceFields '
'showInteractionForceFields')
rootNode.findData('gravity').value = [0, 0, 0]
rootNode.findData('dt').value = 0.02
rootNode.addObject('FreeMotionAnimationLoop')
rootNode.addObject('QPInverseProblemSolver', printLog=0, energyWeight=1e-1, maxIterations=1000, tolerance=1e-5)
rootNode.addObject('BackgroundSetting', color=[1, 1, 1, 1])
rootNode.addObject('LightManager')
rootNode.addObject('PositionalLight', name="light1", color=[0.8, 0.8, 0.8, 1], position=[0, 60, -50])
rootNode.addObject('PositionalLight', name="light2", color=[0.8, 0.8, 0.8, 1], position=[0, -60, 50])
VolumetricMeshPath = MeshesPath + 'Accordeon_Volumetric.vtk'
SurfaceMeshPath = MeshesPath + 'Accordeon_Surface.stl'
CavitySurfaceMeshPath = MeshesPath + 'Accordeon_Cavity.stl'
##########################################
# Mechanical Model #
##########################################
model = rootNode.addChild('model')
model.addObject('EulerImplicitSolver')
model.addObject('SparseLDLSolver', template="CompressedRowSparseMatrixd")
model.addObject('MeshVTKLoader', name='loader', filename=VolumetricMeshPath, scale3d=[1, 1, 1])
model.addObject('MeshTopology', src='@loader', name='container')
model.addObject('MechanicalObject')
model.addObject('UniformMass', totalMass=0.1)
model.addObject('TetrahedronFEMForceField',
poissonRatio=Const.PoissonRation, youngModulus=Const.YoungsModulus)
model.addObject('BoxROI', box=Const.FixedBoxCoords, drawBoxes=True)
model.addObject('RestShapeSpringsForceField', points=model.BoxROI.indices.linkpath, stiffness=1e12)
model.addObject('LinearSolverConstraintCorrection')
##########################################
# Pressure/Volume Equality #
##########################################
accordeonCavity = model.addChild('AccordeonCavity')
accordeonCavity.addObject('MeshSTLLoader', name='loader', filename=CavitySurfaceMeshPath)
accordeonCavity.addObject('MeshTopology', name='topology', src='@loader')
accordeonCavity.addObject('MechanicalObject', src="@topology")
# Here you can set the desired volume to reach
accordeonCavity.addObject('SurfacePressureEquality', template='Vec3', triangles='@topology.triangles',
eqVolumeGrowth=500)
accordeonCavity.addObject('BarycentricMapping')
##########################################
# Visualization #
##########################################
modelVisu = model.addChild('visu')
modelVisu.addObject('MeshSTLLoader', filename=SurfaceMeshPath, name="loader")
modelVisu.addObject('OglModel', src="@loader", scale3d=[1, 1, 1],
material="Default Diffuse 1 0.8 0.8 0.8 0.95 Ambient 0 0.2 0 0 1 "
"Specular 0 1 0 0 1 Emissive 0 1 0 0 1 Shininess 0 45")
modelVisu.addObject('BarycentricMapping')
rootNode.addObject(Controller(name="EqualityController", RootNode=rootNode))
return rootNode