0
|
1 #!/usr/bin/env python
|
|
2 import argparse
|
|
3 import shutil
|
|
4
|
|
5 import icqsol_utils
|
|
6
|
|
7 # Parse Command Line.
|
|
8 parser = argparse.ArgumentParser()
|
|
9 parser.add_argument('--input', dest='input', help='Shape dataset selected from history')
|
|
10 parser.add_argument('--input_file_format_and_type', dest='input_file_format_and_type', help='Input file format and type')
|
|
11 parser.add_argument('--input_dataset_type', dest='input_dataset_type', help='Input dataset_type')
|
|
12 parser.add_argument('--input_potential_name', dest='input_potential_name', default='', help='Input surface potential field name.')
|
|
13 parser.add_argument('--output_jump_electric_field_name', dest='output_jump_electric_field_name', default='jump_normal_electric_field', help='Set the name of the output field name.')
|
|
14 parser.add_argument('--output', dest='output', help='Output dataset')
|
|
15 parser.add_argument('--output_vtk_type', dest='output_vtk_type', help='Output VTK type')
|
|
16
|
|
17 args = parser.parse_args()
|
|
18
|
|
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()
|
|
21
|
|
22 # Instantiate the shape manager.
|
|
23 shape_mgr = icqsol_utils.get_shape_manager(input_format, args.input_dataset_type)
|
1
|
24
|
0
|
25 # Get the vtk polydata from the input dataset.
|
|
26 vtk_poly_data = shape_mgr.loadAsVtkPolyData(args.input)
|
1
|
27
|
0
|
28 # Instantiate the Laplace solver.
|
|
29 solver = icqsol_utils.get_laplace_solver(vtk_poly_data)
|
1
|
30
|
0
|
31 # Set the output field names.
|
|
32 solver.setNormalElectricFieldJumpName(args.output_jump_electric_field_name)
|
1
|
33
|
0
|
34 # In place operation, vtk_poly_data will be modified.
|
|
35 normalEJump = solver.computeNormalElectricFieldJump(potName=args.input_potential_name)
|
1
|
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)
|
2
|
39 print 'min/max values of normal electric field jump: {0}/{1}'.format(minVal, maxVal)
|
1
|
40
|
0
|
41 # Define the output file format and type (the output_format can only be 'vtk').
|
|
42 output_format, output_file_type = icqsol_utils.get_format_and_type(args.output_vtk_type)
|
|
43 tmp_output_path = icqsol_utils.get_temporary_file_path(tmp_dir, output_format)
|
1
|
44
|
0
|
45 # Make sure the ShapeManager's writer is vtk.
|
|
46 shape_mgr.setWriter(file_format=icqsol_utils.VTK, vtk_dataset_type=icqsol_utils.POLYDATA)
|
1
|
47
|
0
|
48 # Save the output.
|
|
49 shape_mgr.saveVtkPolyData(vtk_poly_data=solver.getVtkPolyData(), file_name=tmp_output_path, file_type=output_file_type)
|
|
50 shutil.move(tmp_output_path, args.output)
|