petsc-3.10.5 2019-03-28
Report Typos and Errors

# MatAssemblyEnd

Completes assembling the matrix. This routine should be called after MatAssemblyBegin().

### Synopsis

    #include "petscmat.h"
    PetscErrorCode MatAssemblyEnd(Mat mat,MatAssemblyType type)

Collective on Mat

### Input Parameters

| mat | - the matrix
| type | - type of assembly, either MAT_FLUSH_ASSEMBLY or MAT_FINAL_ASSEMBLY

### Options Database Keys

| -mat_view ::ascii_info | - Prints info on matrix at conclusion of MatEndAssembly()
| -mat_view ::ascii_info_detail | - Prints more detailed info
| -mat_view | - Prints matrix in ASCII format
| -mat_view ::ascii_matlab | - Prints matrix in Matlab format
| -mat_view draw | - PetscDraws nonzero structure of matrix, using MatView() and PetscDrawOpenX().
| -display <name> | - Sets display name (default is host)
| -draw_pause <sec> | - Sets number of seconds to pause after display
| -mat_view socket | - Sends matrix to socket, can be accessed from Matlab (See Users-Manual: Chapter 12 Using MATLAB with PETSc )
| -viewer_socket_machine <machine> | - Machine to use for socket
| -viewer_socket_port <port> | - Port number to use for socket
| -mat_view binary:filename[:append] | - Save matrix to file in binary format

### Notes

MatSetValues() generally caches the values. The matrix is ready to use only after MatAssemblyBegin() and MatAssemblyEnd() have been called. Use MAT_FLUSH_ASSEMBLY when switching between ADD_VALUES and INSERT_VALUES in MatSetValues(); use MAT_FINAL_ASSEMBLY for the final assembly before using the matrix.

Space for preallocated nonzeros that is not filled by a call to MatSetValues() or a related routine are compressed out by assembly. If you intend to use that extra space on a subsequent assembly, be sure to insert explicit zeros before MAT_FINAL_ASSEMBLY so the space is not compressed out.

### See Also

MatAssemblyBegin(), MatSetValues(), PetscDrawOpenX(), PetscDrawCreate(), MatView(), MatAssembled(), PetscViewerSocketOpen()

### Level

beginner

### Location

src/mat/interface/matrix.c

### Examples

src/mat/examples/tutorials/ex2.c.html
src/mat/examples/tutorials/ex4.c.html
src/mat/examples/tutorials/ex5.c.html
src/mat/examples/tutorials/ex8.c.html
src/mat/examples/tutorials/ex12.c.html
src/mat/examples/tutorials/ex15.c.html
src/mat/examples/tutorials/ex16.c.html
src/mat/examples/tutorials/ex17.c.html
src/ksp/pc/examples/tutorials/ex1.c.html
src/ksp/pc/examples/tutorials/ex2.c.html
src/ksp/pc/examples/tutorials/ex3.c.html

### Implementations

MatAssemblyEnd_HYPREStruct in src/dm/impls/da/hypre/mhyp.c
MatAssemblyEnd_HYPRESStruct in src/dm/impls/da/hypre/mhyp.c
MatAssemblyEnd_MPIAIJCRL in src/mat/impls/aij/mpi/crl/mcrl.c
MatAssemblyEnd_MPIAIJ in src/mat/impls/aij/mpi/mpiaij.c
MatAssemblyEnd_MPIAIJCUSPARSE in src/mat/impls/aij/mpi/mpicusparse/mpiaijcusparse.cu
MatAssemblyEnd_MPIAIJViennaCL in src/mat/impls/aij/mpi/mpiviennacl/mpiaijviennacl.cxx
MatAssemblyEnd_SeqAIJ in src/mat/impls/aij/seq/aij.c
MatAssemblyEnd_SeqAIJMKL in src/mat/impls/aij/seq/aijmkl/aijmkl.c
MatAssemblyEnd_SeqAIJPERM in src/mat/impls/aij/seq/aijperm/aijperm.c
MatAssemblyEnd_SeqAIJSELL in src/mat/impls/aij/seq/aijsell/aijsell.c
MatAssemblyEnd_SeqAIJCRL in src/mat/impls/aij/seq/crl/crl.c
MatAssemblyEnd_SeqAIJ_Inode in src/mat/impls/aij/seq/inode2.c
MatAssemblyEnd_SeqAIJCUSPARSE in src/mat/impls/aij/seq/seqcusparse/aijcusparse.cu
MatAssemblyEnd_SeqAIJViennaCL in src/mat/impls/aij/seq/seqviennacl/aijviennacl.cxx
MatAssemblyEnd_MPIBAIJ in src/mat/impls/baij/mpi/mpibaij.c
MatAssemblyEnd_SeqBAIJ in src/mat/impls/baij/seq/baij.c
MatAssemblyEnd_SeqBAIJMKL in src/mat/impls/baij/seq/baijmkl/baijmkl.c
MatAssemblyEnd_BlockMat in src/mat/impls/blockmat/seq/blockmat.c
MatAssemblyEnd_Composite in src/mat/impls/composite/mcomposite.c
MatAssemblyEnd_MPIDense in src/mat/impls/dense/mpi/mpidense.c
MatAssemblyEnd_SeqDense in src/mat/impls/dense/seq/dense.c
MatAssemblyEnd_Elemental in src/mat/impls/elemental/matelem.cxx
MatAssemblyEnd_HYPRE in src/mat/impls/hypre/mhypre.c
MatAssemblyEnd_IS in src/mat/impls/is/matis.c
MatAssemblyEnd_MFFD in src/mat/impls/mffd/mffd.c
MatAssemblyEnd_Nest in src/mat/impls/nest/matnest.c
MatAssemblyEnd_Preallocator in src/mat/impls/preallocator/matpreallocator.c
MatAssemblyEnd_MPISBAIJ in src/mat/impls/sbaij/mpi/mpisbaij.c
MatAssemblyEnd_SeqSBAIJ_SeqAIJ_Inode in src/mat/impls/sbaij/seq/sbaij.c
MatAssemblyEnd_SeqSBAIJ in src/mat/impls/sbaij/seq/sbaij.c
MatAssemblyEnd_MPISELL in src/mat/impls/sell/mpi/mpisell.c
MatAssemblyEnd_SeqSELL in src/mat/impls/sell/seq/sell.c
MatAssemblyEnd_Shell in src/mat/impls/shell/shell.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages