예제 #1
0
    def _permutation_load(tensor, directory, filename, form, form_name,
                          mpi_comm):
        if form_name not in _permutation_storage:
            if not PickleIO.exists_file(directory, "." + form_name):
                raise OSError
            else:
                V_0 = wrapping.form_argument_space(form, 0)
                V_0__dof_map_reader_mapping = wrapping.build_dof_map_reader_mapping(
                    V_0)
                V_0__dof_map_writer_mapping = PickleIO.load_file(
                    directory, "." + form_name)
                vector_permutation = dict(
                )  # from index at time of saving to current index
                writer_vec = _vector_load(directory, filename, mpi_comm)
                writer_row_start, writer_row_end = writer_vec.getOwnershipRange(
                )
                for writer_row in range(writer_row_start, writer_row_end):
                    (global_cell_index,
                     cell_dof) = V_0__dof_map_writer_mapping[writer_row]
                    vector_permutation[
                        writer_row] = V_0__dof_map_reader_mapping[
                            global_cell_index][cell_dof]
                _permutation_storage[form_name] = vector_permutation

        return _permutation_storage[form_name]
예제 #2
0
파일: tensor_save.py 프로젝트: ljnpu/RBniCS
 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)
예제 #3
0
    def _permutation_load(tensor, directory, filename, form, form_name, mpi_comm):
        if form_name not in _permutation_storage:
            if not PickleIO.exists_file(directory, "." + form_name):
                raise OSError
            else:
                V_0 = wrapping.form_argument_space(form, 0)
                V_1 = wrapping.form_argument_space(form, 1)
                V_0__dof_map_reader_mapping = wrapping.build_dof_map_reader_mapping(V_0)
                V_1__dof_map_reader_mapping = wrapping.build_dof_map_reader_mapping(V_1)
                (V_0__dof_map_writer_mapping, V_1__dof_map_writer_mapping) = PickleIO.load_file(
                    directory, "." + form_name)
                matrix_row_permutation = dict()  # from row index at time of saving to current row index
                matrix_col_permutation = dict()  # from col index at time of saving to current col index
                writer_mat = _matrix_load(directory, filename, mpi_comm)
                writer_row_start, writer_row_end = writer_mat.getOwnershipRange()
                for writer_row in range(writer_row_start, writer_row_end):
                    (global_cell_index, cell_dof) = V_0__dof_map_writer_mapping[writer_row]
                    matrix_row_permutation[writer_row] = V_0__dof_map_reader_mapping[global_cell_index][cell_dof]
                    writer_cols, _ = writer_mat.getRow(writer_row)
                    for writer_col in writer_cols:
                        if writer_col not in matrix_col_permutation:
                            (global_cell_index, cell_dof) = V_1__dof_map_writer_mapping[writer_col]
                            matrix_col_permutation[writer_col] = V_1__dof_map_reader_mapping[
                                global_cell_index][cell_dof]
                _permutation_storage[form_name] = (matrix_row_permutation, matrix_col_permutation)

        return _permutation_storage[form_name]
예제 #4
0
파일: tensor_save.py 프로젝트: ljnpu/RBniCS
 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)