Beispiel #1
0
 def equilibriumSolver(tgtAngle, l, opts, fv):
     opts.beta = 1e-8
     opts.gradTol = 1e-6
     opts.useIdentityMetric = True
     if (tgtAngle != None):
         return elastic_rods.compute_equilibrium(l,
                                                 tgtAngle,
                                                 options=opts,
                                                 fixedVars=fv)
     else:
         return elastic_rods.compute_equilibrium(l,
                                                 options=opts,
                                                 fixedVars=fv)
def equilibriumSolver(tgtAngle, l, opts, fv):
    opts.useIdentityMetric = False
    opts.beta = 1e-8
    return elastic_rods.compute_equilibrium(l,
                                            tgtAngle,
                                            options=opts,
                                            fixedVars=fv)
def runTest(L, a, numVertices, gradTol=None):
    r, fixedVars = bendingTestRod(L, a, numVertices)
    t = time.time()
    opts = elastic_rods.NewtonOptimizerOptions()
    opts.verbose = False
    opts.niter = 1000
    opts.useIdentityMetric = False
    opts.useNegativeCurvatureDirection = True
    if (gradTol is not None):
        opts.gradTol = gradTol
    cr = elastic_rods.compute_equilibrium(r, options=opts, fixedVars=fixedVars)
    # if (gradTol is None): elastic_rods.compute_equilibrium_knitro(r, verbose=False, fixedVars=fixedVars, niter=1000)
    # else:                 elastic_rods.compute_equilibrium_knitro(r, verbose=False, fixedVars=fixedVars, niter=1000)
    simTime = time.time() - t

    arod = AnalyticRod(L, a)
    return r, arod, simTime, cr.numIters()
# driver=48
# linkage = elastic_rods.RodLinkage('../examples/florin/20181114_134207_meshID_34b18bdf-8314-454a-96de-b2b2d7356db1.obj', 10)
driver = 64
linkage = elastic_rods.RodLinkage('../examples/nonuniform_linkage.obj', 10)
mat = elastic_rods.RodMaterial('+', 2000, 0.3, [0.02, 0.02, 0.002, 0.002])
# mat = elastic_rods.RodMaterial('ellipse', 20000, 0.3, [0.02, 0.002])
linkage.setMaterial(mat)

elastic_rods.benchmark_reset()
elastic_rods.restlen_solve(linkage)

jdo = linkage.dofOffsetForJoint(driver)
fixedVars = list(range(jdo, jdo + 6))  # fix rigid motion for a single joint
fixedVars.append(jdo + 6)  # constrain angle at the driving joint

elastic_rods.compute_equilibrium(linkage, fixedVars=fixedVars)


def equilibriumSolver(tgtAngle, l, opts, fv):
    opts.useIdentityMetric = False
    opts.beta = 1e-8
    return elastic_rods.compute_equilibrium(l,
                                            tgtAngle,
                                            options=opts,
                                            fixedVars=fv)


#cr = open_linkage(linkage, driver, np.pi/4, 25, None, zPerturbationEpsilon=0, equilibriumSolver=equilibriumSolver, verbose=1, useTargetAngleConstraint=False)
cr = open_linkage(linkage,
                  driver,
                  np.pi / 8,