parallel.py

Define classes and functions for parallel computations within PETGEM.

petgem.parallel.createParallelDenseMatrix(dimension1, dimension2, communicator=None)[source]

Create a parallel dense matrix in petsc format.

Parameters
  • dimension1 (int) – matrix dimension (rows).

  • dimension2 (int) – matrix dimension (columns).

  • communicator (str) – mpi communicator.

Returns

parallel matrix.

Return type

petsc parallel and dense matrix.

petgem.parallel.createParallelMatrix(dimension1, dimension2, nnz, matrix_type, communicator=None)[source]

Create a parallel sparse matrix in petsc format.

Parameters
  • dimension1 (int) – matrix dimension (rows).

  • dimension2 (int) – matrix dimension (columns).

  • nnz (int) – not zero pattern for allocation.

  • matrix_type (int) – matrix type for parallel computations.

  • communicator (str) – mpi communicator.

Returns

parallel matrix.

Return type

petsc AIJ parallel matrix.

petgem.parallel.createParallelVector(size, vector_type, communicator=None)[source]

Create a parallel vector in petsc format.

Parameters
  • size (int) – vector size.

  • vector_type (int) – vector type for parallel computations.

  • communicator (str) – mpi communicator.

Returns

parallel vector.

Return type

petsc parallel vector.

petgem.parallel.createSequentialDenseMatrixWithArray(dimension1, dimension2, data)[source]

Given an input array, create a sequential dense matrix in petsc format.

Parameters
  • dimension1 (int) – matrix dimension (rows).

  • dimension2 (int) – matrix dimension (columns).

  • data (ndarray) – data to be exported.

Returns

parallel matrix.

Return type

petsc parallel and dense matrix.

petgem.parallel.createSequentialVector(size, vector_type, communicator=None)[source]

Create a sequential vector in petsc format.

Parameters
  • size (int) – vector size.

  • vector_type (int) – vector type for parallel computations.

  • communicator (str) – mpi communicator.

Returns

sequential vector.

Return type

petsc sequential vector.

petgem.parallel.createSequentialVectorWithArray(data)[source]

Given an input array, create a sequential vector in petsc format.

Parameters

data (ndarray) – data to be exported.

Returns

parallel matrix.

Return type

petsc parallel and dense matrix.

petgem.parallel.readPetscMatrix(input_file, communicator=None)[source]

Read a Petsc matrix which format is defined by two files: input_file.dat and input_file.info.

Parameters
  • input_file (str) – file name to be readed.

  • communicator (str) – mpi communicator.

Returns

petsc_matrix.

Return type

petsc sparse matrix.

petgem.parallel.readPetscVector(input_file, communicator=None)[source]

Read a Petsc vector which format is defined by two files: input_file.dat and input_file.info.

Parameters
  • input_file (str) – file name to be readed.

  • communicator (str) – mpi communicator.

Returns

petsc_vector.

Return type

petsc vector.

petgem.parallel.unitary_test()[source]

Unitary test for parallel.py script.

petgem.parallel.writeDenseMatrix(output_file, data, communicator=None)[source]

Write a Petsc dense matrix which format is defined by two files: output_file.dat and output_file.info.

Parameters
  • output_file (str) – file name to be saved.

  • matrix data (petsc) – dense matrix to be saved.

  • communicator (str) – mpi communicator.

Returns

None.

petgem.parallel.writeParallelDenseMatrix(output_file, data, communicator=None)[source]

Write a Petsc parallel dense matrix which format is defined by two files: output_file.dat and output_file.info.

Parameters
  • output_file (str) – file name to be saved.

  • matrix data (petsc) – dense matrix to be saved.

  • communicator (str) – mpi communicator.

Returns

None.

petgem.parallel.writePetscVector(output_file, data, communicator=None)[source]

Write a Petsc vector which format is defined by two files: output_file.dat and output_file.info.

Parameters
  • output_file (str) – file name to be saved.

  • vector data (petsc) – array to be saved.

  • communicator (str) – mpi communicator.

Returns

None.