print '\tPerformed ii_assemble in %g s' % t.stop() wh = ii_Function(W) t = Timer('convert'); t.start() AAm, bbm = map(ii_convert, (AA, bb)) print '\tPerformed ii_convert in %g s' % t.stop() t = Timer('solve'); t.start() LUSolver('umfpack').solve(AAm, wh.vector(), bbm) print '\tSolved in %g s' % t.stop() for i, wh_i in enumerate(wh): wh_i.rename('u', str(i)) File('./u%d.pvd' % i) << wh_i # -------------------------------------------------------------------- if __name__ == '__main__': f = Expression('sin(pi*(x[0]+x[1]+x[2]))', degree=3) # Setup the mesh_generator for the random curve import meshing # Using 1/4 of the default mesh sizes, the inner box is [-1/2, 1/2]^3 # and thee random curve will be made using 40 vertices mesh_generator = lambda :meshing.load(scale=2./8, inner_size=0.5, curve_gen=lambda mesh: meshing.fun(mesh, 40)) main(f, mesh_generator)
parser.add_argument('-radius', type=float, default=0.1, help='Radius of the tubes') # Solver parser.add_argument('-solver', type=str, default='direct', choices=['direct', 'iterative'], help='Use direct solver with params as in main') args, petsc_args = parser.parse_known_args() # Let's rock mesh_gen = lambda: meshing.load( args.scale, lambda mesh: meshing.fun(mesh, npoints=args.npoints)) timer = Timer('setup') timer.start() AA, bb, W, p_const = setup_problem(args.radius, mesh_gen) print '\tProblem setup took %g s\n \tNumber of unknowns %d ' % ( timer.stop(), sum(Wi.dim() for Wi in W)) x = AA * bb y = AA.transpmult(bb) assert (x - y).norm() < 1E-14, 'AA is not symmetric!' wh = ii_Function(W) timer = Timer('solver') timer.start()
help='Scale mesh size relative to definition in geo') parser.add_argument('-npoints', type=int, default=80, help='Num points to draw the curve') parser.add_argument('-radius', type=float, default=0.1, help='Radius of the tubes') # Solver parser.add_argument('-solver', type=str, default='direct', choices=['direct', 'iterative'], help='Use direct solver with params as in main') args, petsc_args = parser.parse_known_args() # Let's rock mesh_gen = lambda: meshing.load(args.scale, lambda mesh: meshing.fun(mesh, npoints=args.npoints)) timer = Timer('setup'); timer.start() AA, bb, W, p_const = setup_problem(args.radius, mesh_gen) print '\tProblem setup took %g s\n \tNumber of unknowns %d ' % (timer.stop(), sum(Wi.dim() for Wi in W)) x = AA*bb y = AA.transpmult(bb) assert (x-y).norm() < 1E-14, 'AA is not symmetric!' wh = ii_Function(W) timer = Timer('solver'); timer.start() if args.solver == 'direct': # Convert AAm, bbm = map(ii_convert, (AA, bb))