Exemple #1
0
 def _permutation_save(tensor, directory, form, form_name, mpi_comm):
     if not PickleIO.exists_file(directory, "." + form_name):
         V_0 = wrapping.form_argument_space(form, 0)
         V_1 = wrapping.form_argument_space(form, 1)
         V_0__dof_map_writer_mapping = wrapping.build_dof_map_writer_mapping(
             V_0)
         V_1__dof_map_writer_mapping = wrapping.build_dof_map_writer_mapping(
             V_1)
         matrix_row_mapping = dict(
         )  # from processor dependent row indices to processor independent tuple
         matrix_col_mapping = dict(
         )  # from processor dependent col indices to processor independent tuple
         mat = wrapping.to_petsc4py(tensor)
         row_start, row_end = mat.getOwnershipRange()
         for row in range(row_start, row_end):
             matrix_row_mapping[row] = V_0__dof_map_writer_mapping[row]
             cols, _ = mat.getRow(row)
             for col in cols:
                 if col not in matrix_col_mapping:
                     matrix_col_mapping[col] = V_1__dof_map_writer_mapping[
                         col]
         gathered_matrix_row_mapping = mpi_comm.reduce(matrix_row_mapping,
                                                       root=0,
                                                       op=_dict_update_op)
         gathered_matrix_col_mapping = mpi_comm.reduce(matrix_col_mapping,
                                                       root=0,
                                                       op=_dict_update_op)
         gathered_matrix_mapping = (gathered_matrix_row_mapping,
                                    gathered_matrix_col_mapping)
         PickleIO.save_file(gathered_matrix_mapping, directory,
                            "." + form_name)
Exemple #2
0
 def _permutation_save(tensor, directory, form, form_name, mpi_comm):
     if not PickleIO.exists_file(directory, "." + form_name):
         V_0 = wrapping.form_argument_space(form, 0)
         V_0__dof_map_writer_mapping = wrapping.build_dof_map_writer_mapping(
             V_0)
         vector_mapping = dict(
         )  # from processor dependent indices to processor independent tuple
         vec = wrapping.to_petsc4py(tensor)
         row_start, row_end = vec.getOwnershipRange()
         for row in range(row_start, row_end):
             vector_mapping[row] = V_0__dof_map_writer_mapping[row]
         gathered_vector_mapping = mpi_comm.reduce(vector_mapping,
                                                   root=0,
                                                   op=_dict_update_op)
         PickleIO.save_file(gathered_vector_mapping, directory,
                            "." + form_name)