Mercurial > repos > greg > icqsol_solve_laplace
comparison icqsol_solve_laplace.py @ 1:696bfb47d45e draft
Uploaded
author | greg |
---|---|
date | Mon, 25 Jan 2016 07:53:44 -0500 |
parents | e04795a38512 |
children | 4fc22a63a17e |
comparison
equal
deleted
inserted
replaced
0:e04795a38512 | 1:696bfb47d45e |
---|---|
19 input_format, input_file_type = icqsol_utils.get_format_and_type(args.input_file_format_and_type) | 19 input_format, input_file_type = icqsol_utils.get_format_and_type(args.input_file_format_and_type) |
20 tmp_dir = icqsol_utils.get_temp_dir() | 20 tmp_dir = icqsol_utils.get_temp_dir() |
21 | 21 |
22 # Instantiate the shape manager. | 22 # Instantiate the shape manager. |
23 shape_mgr = icqsol_utils.get_shape_manager(input_format, args.input_dataset_type) | 23 shape_mgr = icqsol_utils.get_shape_manager(input_format, args.input_dataset_type) |
24 | |
24 # Get the vtk polydata from the input dataset. | 25 # Get the vtk polydata from the input dataset. |
25 vtk_poly_data = shape_mgr.loadAsVtkPolyData(args.input) | 26 vtk_poly_data = shape_mgr.loadAsVtkPolyData(args.input) |
27 | |
26 # Instantiate the Laplace solver. | 28 # Instantiate the Laplace solver. |
27 solver = icqsol_utils.get_laplace_solver(vtk_poly_data) | 29 solver = icqsol_utils.get_laplace_solver(vtk_poly_data) |
30 | |
28 # Set the output field names. | 31 # Set the output field names. |
29 solver.setNormalElectricFieldJumpName(args.output_jump_electric_field_name) | 32 solver.setNormalElectricFieldJumpName(args.output_jump_electric_field_name) |
33 | |
30 # In place operation, vtk_poly_data will be modified. | 34 # In place operation, vtk_poly_data will be modified. |
31 normalEJump = solver.computeNormalElectricFieldJump(potName=args.input_potential_name) | 35 normalEJump = solver.computeNormalElectricFieldJump(potName=args.input_potential_name) |
36 surfIntegral = shape_mgr.integrateSurfaceField(solver.getVtkPolyData(), args.output_jump_electric_field_name) | |
37 print 'Surface integral of normal electric field jump: {0}'.format(surfIntegral) | |
38 minVal, maxVal = shape_mgr.getFieldRange(solver.getVtkPolyData(), args.output_jump_electric_field_name) | |
39 print 'min/max values of normal electrc field jump: {0}/{1}'.format(minVal, maxVal) | |
40 | |
32 # Define the output file format and type (the output_format can only be 'vtk'). | 41 # Define the output file format and type (the output_format can only be 'vtk'). |
33 output_format, output_file_type = icqsol_utils.get_format_and_type(args.output_vtk_type) | 42 output_format, output_file_type = icqsol_utils.get_format_and_type(args.output_vtk_type) |
34 tmp_output_path = icqsol_utils.get_temporary_file_path(tmp_dir, output_format) | 43 tmp_output_path = icqsol_utils.get_temporary_file_path(tmp_dir, output_format) |
44 | |
35 # Make sure the ShapeManager's writer is vtk. | 45 # Make sure the ShapeManager's writer is vtk. |
36 shape_mgr.setWriter(file_format=icqsol_utils.VTK, vtk_dataset_type=icqsol_utils.POLYDATA) | 46 shape_mgr.setWriter(file_format=icqsol_utils.VTK, vtk_dataset_type=icqsol_utils.POLYDATA) |
47 | |
37 # Save the output. | 48 # Save the output. |
38 shape_mgr.saveVtkPolyData(vtk_poly_data=solver.getVtkPolyData(), file_name=tmp_output_path, file_type=output_file_type) | 49 shape_mgr.saveVtkPolyData(vtk_poly_data=solver.getVtkPolyData(), file_name=tmp_output_path, file_type=output_file_type) |
39 shutil.move(tmp_output_path, args.output) | 50 shutil.move(tmp_output_path, args.output) |