parallel.py

Define parallel functions for Edge Finite Element Method (EFEM) of lowest order in tetrahedral meshes, namely, Nedelec elements.

petgem.parallel.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.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.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.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.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.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.parallel.getRanges(elemsE, boundaries, receivers, size, rank)[source]

Get owner ship ranges of matrices and vectors for parallel computations.

Parameters:
  • matrix elemsE (petsc) – elements-edges connectivity.
  • vector boundaries (petsc) – boundary indexes.
  • matrix receivers (petsc) – receivers matrix.
  • size (int) – size of the parallel pool.
Para int rank:

MPI rank.

Returns:

Istart_elemsE, Iend_elemsE, Istart_bEdges, Iend_bEdges, Istart_boundaries, Iend_boundaries, Istart_receivers, Iend_receivers.

Return type:

int

petgem.parallel.parallel.getRankSize()[source]

Get information of parallel pool, namely Rank and size. Furthermore, here is defined the Rank==0 as MASTER whithin the parallel pool.

Param:None.
Returns:MASTER, rank, size.
Return type:integer.
petgem.parallel.parallel.parallelAssembler(modelling, A, b, nodes, elemsE, elemsN, elemsF, facesN, elemsSigma, Istart_elemsE, Iend_elemsE, nEdges, nFaces, rank)[source]

Assembly matrix A and vector b for 3D CSEM in parallel.

Parameters:
  • modelling (dictionary) – CSEM modelling with physical parameters.
  • matrix A (petsc) – left-hand side.
  • vector b (petsc) – right-hand side.
  • matrix nodes (petsc) – nodal coordinates.
  • matrix elemsE (petsc) – elements-edges connectivity.
  • matrix elemsN (petsc) – elements-nodes connectivity.
  • matrix elemsF (petsc) – elements-faces connectivity.
  • matrix facesN (petsc) – faces-nodes connectivity.
  • vector elemsSigma (petsc) – elements-conductivity array.
  • Istart_elemsE (int) – init range for assembly.
  • Iend_elemsE (int) – last range for assembly.
  • nEdges (int) – total number of edges in the mesh.
Para int rank:

MPI rank.

Returns:

matrix A, vector b assembled, elapsedTimeAssembly.

Return type:

petsc matrix, petsc vector and float.

petgem.parallel.parallel.printMessage(msg, rank)[source]

Master prints a message in a parallel pool.

Parameters:
  • msg (str) – message to be printed.
  • rank (int) – MPI rank.
Returns:

None.

petgem.parallel.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.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.parallel.unitary_test()[source]

Unitary test for parallel.py script.

petgem.parallel.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.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.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.