Skip to content

Instantly share code, notes, and snippets.

@zbounik zbounik/main

Created Sep 22, 2019
Embed
What would you like to do?
import Sofa
def createScene(rootNode):
rootNode.createObject('RequiredPlugin', name='SofaPython')
mySimulation = AttachConstraint_Zahra2_surface_OK3(rootNode,[])
return 0;
class AttachConstraint_Zahra2_surface_OK3 (Sofa.PythonScriptController):
def initGraph(self,rootNode):
# rootNode
rootNode.createObject('DefaultPipeline', name='CollisionPipeline', verbose='0')
rootNode.createObject('BruteForceDetection', name='N2')
rootNode.createObject('DefaultContactManager', name='collision response', response='default')
rootNode.createObject('DiscreteIntersection', name='discreteIntersection1')
# rootNode.createObject('PythonScriptController', classname="controller", filename='MutimediaExperimental_controller.py')
# rootNode/AttachCoarseToFine
AttachCoarseToFine = rootNode.createChild('AttachCoarseToFine')
AttachCoarseToFine.createObject('EulerImplicitSolver', name='cg_odesolver', printLog='0')
AttachCoarseToFine.createObject('CGLinearSolver', threshold='1e-09', tolerance='1e-09', name='linear solver', iterations='25', template='GraphScattered')
# rootNode/AttachCoarseToFine/Coarse
Coarse = AttachCoarseToFine.createChild('Coarse')
Coarse.depend = 'topo dofs'
Coarse.createObject('MeshGmshLoader', tetrahedraGroups=' -1 0 596', name='loader', filename='livertetra181.gmsh')
Coarse.createObject('TetrahedronSetTopologyContainer', triangles='@loader.triangles', position='@loader.position', edges='@loader.edges', name='topo', tetrahedra='@loader.tetras')
Coarse.createObject('MechanicalObject', force='0 0 0', name='CoarseMechVolume', template='Vec3d', position='@loader.position', velocity='0 0 0', externalForce='0 0 0', restScale='1')
Coarse.createObject('TetrahedronSetGeometryAlgorithms', drawColorEdges='0.4 1 0.298039 1', name='GeomAlgo', showPointIndices='1', template='Vec3d')
Coarse.createObject('DiagonalMass', massDensity='1', name='computed using mass density', template='Vec3d')
Coarse.createObject('TetrahedralCorotationalFEMForceField', poissonRatio='0.45', name='FEM', computeGlobalMatrix='0', method='large', template='Vec3d', youngModulus='1000')
Coarse.createObject('PlaneForceField', name='planeFF0', template='Vec3d', normal='0 1 0')
Coarse.createObject('ConstantForceField', indices='75', forces='0 -700 0', showColor='0.2 0.894118 0.294118 1', template='Vec3d', name='constantFF0')
Coarse.createObject('FixedConstraint', indices='11 17 16 15 14 4 3 0 45 95 42 40 38 39 53 62 61 60 4 63 59 125 24 20 19 9', drawSize='0', name='fixedConstraint0', template='Vec3d')
Coarse.createObject('TetrahedronSetTopologyModifier', name='tetrahedronSetTopologyModifier9')
Coarse.createObject('TetrahedronSetTopologyAlgorithms', name='tetrahedronSetTopologyAlgorithms10', template='Vec3d')
Coarse.createObject('MeshExporter', exportEveryNumberOfSteps='1', quads='0', name='meshExporter1', format='gmsh', exportAtEnd='1', filename='AttachLiverVolumeCoarseOneWay_'+str(Coarse.getObject('constantFF0').findData('forces').value[0])+'_'+str(Coarse.getObject('constantFF0').findData('indices').value[0]), exportAtBegin='0', tetras='1', hexas='0', edges='0', triangles='0', listening='0')
Visu_coarse = Coarse.createChild('Visu-coarse')
Visu_coarse.createObject('OglModel', sfactor='GL_SRC_ALPHA', name='oglModel1', material='Default Diffuse 1 0 0 1 1 Ambient 1 0 0 0.2 1 Specular 0 0 0 1 1 Emissive 0 0 0 1 1 Shininess 0 45 ', primitiveType='DEFAULT', template='ExtVec3f', translation='0 0 0', dfactor='GL_ONE_MINUS_SRC_ALPHA', blendEquation='GL_FUNC_ADD')
Visu_coarse.createObject('IdentityMapping', input='@../', name='identityMap2', template='Vec3d,ExtVec3f', output='@./')
# rootNode/AttachCoarseToFine/Fine
Fine = AttachCoarseToFine.createChild('Fine')
Fine.createObject('MeshGmshLoader', tetrahedraGroups=' -1 0 38144', name='meshGmshLoader1', filename='livertetra7509.msh')
#/home/zahra/sofa/Work/Exported/undeformed_meshes_editAbovePlaneForceField/InputLiverVolumeFine.gmsh
Fine.createObject('TetrahedronSetTopologyContainer', triangles='@meshGmshLoader1.triangles', position='@meshGmshLoader1.position', edges='@meshGmshLoader1.edges', name='tetrahedronSetTopologyContainer2', tetrahedra='@meshGmshLoader1.tetras')
Fine.createObject('MechanicalObject', force='0 0 0', name='FineMechVolume', template='Vec3d', position='@meshGmshLoader1.position', velocity='0 0 0', externalForce='0 0 0', restScale='1')
Fine.createObject('TetrahedronSetTopologyModifier', name='tetrahedronSetTopologyModifier3')
Fine.createObject('TetrahedronSetGeometryAlgorithms', drawColorEdges='0.4 1 0.298039 1', recomputeTrianglesOrientation='0', name='tetrahedronSetGeometryAlgorithms0', showPointIndices='0', flipNormals='1', template='Vec3d')
Fine.createObject('TetrahedronSetTopologyAlgorithms', name='tetrahedronSetTopologyAlgorithms1', template='Vec3d')
Fine.createObject('DiagonalMass', name='diagonalMass4', template='Vec3d')
Fine.createObject('TetrahedralCorotationalFEMForceField', youngModulus='1000', name='tetrahedralCorotationalFEMFF5', poissonRatio='0.45', template='Vec3d')
Fine.createObject('PlaneForceField', name='planeFF6', template='Vec3d', normal='0 1 0')
Fine.createObject('FixedConstraint', indices='11 17 16 15 14 4 3 0 45 95 42 40 38 39 53 62 61 60 4 63 59 125 24 20 19 9', name='fixedConstraint7', template='Vec3d')
Fine.createObject('MeshExporter', exportEveryNumberOfSteps='1', quads='0', name='meshExporter4', format='gmsh', exportAtEnd='1', filename='AttachLiverVolumeFineOneWay_'+str(Coarse.getObject('constantFF0').findData('forces').value[0])+'_'+str(Coarse.getObject('constantFF0').findData('indices').value[0]), exportAtBegin='1', hexas='0', edges='0', triangles='0')
Visu_fine = Fine.createChild('Visu-fine')
Visu_fine.createObject('OglModel', sfactor='GL_SRC_ALPHA', blendEquation='GL_FUNC_ADD', name='oglModel0', template='ExtVec3f', dfactor='GL_ONE_MINUS_SRC_ALPHA', material='Default Diffuse 1 0.666667 0 0 1 Ambient 1 0.2 0.2 0.2 1 Specular 0 1 1 1 1 Emissive 0 0 0 0 0 Shininess 0 45 ', primitiveType='DEFAULT')
Visu_fine.createObject('IdentityMapping', input='@../', name='identityMap1', template='Vec3d,ExtVec3f', output='@./')
AttachCoarseToFine.createObject('AttachConstraint', object1='@Fine', object2='@Coarse', indices1='75', name='attachConstraint1', template='Vec3d', indices2='75', radius='0.1', twoWay='0')
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.