@@ -78,32 +78,30 @@ def get_petsc_type_mappings():
7878 try :
7979 petsc_precision = petsc_variables ['PETSC_PRECISION' ]
8080 except KeyError :
81- mapper = {}
81+ printer_mapper = {}
8282 else :
8383 petsc_scalar = 'PetscScalar'
8484 # TODO: Check to see whether Petsc is compiled with
8585 # 32-bit or 64-bit integers
86- mapper = {ctypes .c_int : 'PetscInt' }
86+ printer_mapper = {ctypes .c_int : 'PetscInt' }
8787
8888 if petsc_precision == 'single' :
89- mapper [ctypes .c_float ] = petsc_scalar
89+ printer_mapper [ctypes .c_float ] = petsc_scalar
9090 elif petsc_precision == 'double' :
91- mapper [ctypes .c_double ] = petsc_scalar
92- return mapper
91+ printer_mapper [ctypes .c_double ] = petsc_scalar
9392
93+ # Used to construct ctypes.Structures that wrap PETSc objects
94+ petsc_type_to_ctype = {v : k for k , v in printer_mapper .items ()}
95+ # Add other PETSc types
96+ petsc_type_to_ctype .update ({
97+ 'KSPType' : ctypes .c_char_p ,
98+ 'KSPConvergedReason' : petsc_type_to_ctype ['PetscInt' ],
99+ 'KSPNormType' : petsc_type_to_ctype ['PetscInt' ],
100+ })
101+ return printer_mapper , petsc_type_to_ctype
94102
95- # This mapping is used by the printer to always convert
96- # int, float/double to `PetscInt` and `PetscScalar`
97- petsc_type_mappings = get_petsc_type_mappings ()
98103
99-
100- # Used to construct ctypes.Structures that wrap PETSc objects
101- petsc_type_to_ctype = {v : k for k , v in petsc_type_mappings .items ()}
102- petsc_type_to_ctype .update ({
103- 'KSPType' : ctypes .c_char_p ,
104- 'KSPConvergedReason' : petsc_type_to_ctype ['PetscInt' ],
105- 'KSPNormType' : petsc_type_to_ctype ['PetscInt' ],
106- })
104+ petsc_type_mappings , petsc_type_to_ctype = get_petsc_type_mappings ()
107105
108106
109107petsc_languages = ['petsc' ]
0 commit comments