示例#1
0
def writeSolutionVTK(solution, bounds, npoints, realdata=True, fname='solution.vti'):
    from pypwdg.output.vtk_output import VTKStructuredPoints

    print "Evaluate Solution and Write to File"
    
    bounds=np.array(bounds,dtype='d')
    filter=np.real if realdata else np.imag

    vtk_structure=VTKStructuredPoints(solution.getEvaluator(filter))
    vtk_structure.create_vtk_structured_points(bounds,npoints)
    vtk_structure.write_to_file(fname)
示例#2
0
f=f.squeeze()
(X,error)=solve(S,f)


#X = print_timing(spsolve)(S.tocsr(), f.tocsr())

#print X


print "Residual: %e: " % numpy.linalg.norm(S*X-f) 



EvalError=EvalElementError(mesh,elttobasis,quad, bnddata, lv, bndvs)
(ed,en,eb)=EvalError.evaluate(X)
print numpy.linalg.norm(ed),numpy.linalg.norm(en),numpy.linalg.norm(eb)

vtkgrid=VTKGrid(mesh,scalars=ed)
vtkgrid.write('test.vtu')


eval_fun=lambda points: numpy.real(Evaluator(mesh,elttobasis,points).evaluate(X))
bounds=numpy.array([[-2,2],[-2,2],[-2,2]],dtype='d')
npoints=numpy.array([50,50,50])
vtk_structure=VTKStructuredPoints(eval_fun)
vtk_structure.create_vtk_structured_points(bounds,npoints)
vtk_structure.write_to_file('test.vti')
t.split("output")
t.show()