Skip to content
Snippets Groups Projects
Commit 00d34564 authored by Nils-Arne Dreier's avatar Nils-Arne Dreier
Browse files

doc: add some information about the raw_data in CSR format

parent a7b3f969
No related branches found
No related tags found
No related merge requests found
......@@ -221,6 +221,10 @@ accordingly.
`raw_data` is a data class object, see \ref yac.RawInterpWeights "RawInterpWeights"
</table>
Alternatively, the exchange data can also be obtained in a format that
is compatible with the CSR sparse matrix format. See for example \ref
yac_cget_raw_interp_weights_data_csr.
\subsection src_field_buffer_raw_exchange Allocate receive buffers
<table style="border: none;border-collapse: collapse;width:1500px">
......@@ -608,6 +612,17 @@ accordingly.
for tgt_idx, start_idx, end_idx in zip(raw_data.wgt_tgt_idx, indptr[:-1], indptr[1:]):
tgt_buffer[c, tgt_idx] = raw_data.weights[start_idx:end_idx]@buf[c, raw_data.src_idx[start_idx: end_idx]]
\endcode
In the case you have the raw_exchange data in CSR format (see \ref yac.Field.get_raw_interp_weights_data_csr), you can pass the data directly to scipy's `csr_matrix`.
\code{.py}
raw_data_csr = tgt_field.get_raw_interp_weights_data_csr()
W = csr_matrix((raw_data_csr.weights, raw_data_csr.src_idx, raw_data_csr.src_indptr))
tgt_field.get_raw(buf)
for c in range(tgt_field.collection_size):
tgt_buffer[c, :] = W@buf[c, :]
tgt_buffer[c, raw_data_csr.tgt_idx_fixed] = raw_data_csr.fixed_values[0]
\endcode
</table>
\subsection cleanup_raw_exchange Freeing of interpolation information
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment