matrix memory allocation
mafunk at nmsu.edu
Wed Mar 26 15:31:01 CDT 2008
in order to create a sparse MPIMatrix (with preallocated memory) it is
necessary to give it the number of nonzero entries per row for the local and
The way i do things right now is that i need to allocate the entire matrix.
However, my domain is decomposed into boxes where one or more boxes reside on
the current processor.
So, i was wondering if it is possible to allocate the matrix memory per box.
Right now what i do is this:
1) iterate over the whole domain (every single box) and extract the info i
need from each box for memory allocation.
2) call MatCreateMPIAIJ to create the matrix/allocate memory.
3) iterate over the whole domain again to get the info to insert the values
into the matrix.
Is it possible to instead do something like:
1) get info for values and memory allocation needed per box
2) allocate memory for x number of rows in global matrix and insert values for
them (via MatSetValues)
3) start at 1) till every box in the domain is covered.
The problem in 2) is that i can insert the values, but there is no memory
preallocated for it, so it would be slow. If i could allocate it, i think it
would solve my problem.
I hope i am making sense. By the way, i cannot use the DA construct because i
have overlapping values.
More information about the petsc-users