I am working on a domain decomposition code in C that uses CHOLMOD to approximate grid values for a PDE in each sub-domain. The issue I have is that the methods use Matrix Market format, which is not an issue in general, but I already have a method that computes a 2D array which is the sparse matrix A in the Ax=b solve. I am not sure how I could either convert that into a sparse matrix using a method in CHOLMOD or if there was a way to save a Matrix Market text file on each loop call and somehow put it into A = cholmod_read_sparse or something else. Any insight would be much appreciated!
The most efficient way will be to directly use the C API of CHOLMOD and call it directly, without saving the matrix to disk, see my answer to this question for an example (see also CHOLMOD documentation). CHOLMOD uses the standard CRS (compressed row storage) representation. It is explained in many places, see for instance this wikipedia entry.
Clearly, it is also possible, as you suggest, to write the matrix to disk using Matrix Market format and call CHOLMOD by spawning the example program provided with it, but this will be less efficient and will require as much programming effort as calling CHOLMOD directly. If you are not programming in C/C++ or in a language that has CHOLMOD bindings, you may need to do that. The easiest solution for you will be to use the coordinate format. If performance is an issue, you may use CRS format (a little bit more programming effort). Both are explained here.
I do hope that your
A that you assemble is a sparse matrix. Otherwise the use of sparse cholesky factorizations would not make sense. Then, if you didn't do this during the assembling process, you should turn it into a sparse matrix format as soon as possible.
Then -- and not knowing in what environment you are so that I can only guess -- it will be more efficient to pass the matrix directly to
cholmod which will convert it for you (at least in the python interface) without doing the saving/loading step using the
matrix market format.