GithubHelp home page GithubHelp logo

Specifying RHS vector in amgx_capi about amgx HOT 4 CLOSED

nvidia avatar nvidia commented on June 15, 2024
Specifying RHS vector in amgx_capi

from amgx.

Comments (4)

marsaev avatar marsaev commented on June 15, 2024

Hi Robert.

The trick is in two special lines in the matrix header:

%%MatrixMarket matrix coordinate real general
%%AMGX 1 1 sorted rhs solution

For MatrixMarket header we can read 'coordinate', 'general', 'symmetric', 'skew-symmetric', 'real', 'complex' matrices.
For AMGX header we use similar keywords features:

  • Two integers - blocksizes.
  • 'sorted' means nonzero elements are sorted (by-row, by-column).
  • 'diagonal' means that diagonal is stored separately from matrix. N values from input file right after nonzeros will be considered as diagonal and special flag for matrix will be set that diagonal is not stored in CSR structure.
  • 'rhs' means that right hand side is present in this file and N values from input file after matrix will be read as RHS
  • 'solution' means that initial solution present in the file and N values from input file after matrix and (optional) rhs will be read as initial solution to system.

Typically diagonal entries are specified among the rest of nonzeros so it's likely that you should not use 'diagonal' keyword. Note that usually RHS stored is MatrixMarket format, but if you just want to 'cat' it to the main matrix - you should use RHS values only.

Example of matrix with RHS:

%%MatrixMarket matrix coordinate real general
%%AMGX 1 1 sorted rhs
2 2 4
1 1 2.0
1 2 0.5
2 1 0.5
2 2 2.0
0.3
1.5

Here 0.3 and 1.5 are RHS values for row 0 and 1 respectively. Also notice there is no 'diagonal' keyword in the header.

I hope that helps. Please let me know if something is not entirely clear.

Thanks!

from amgx.

robertsawko avatar robertsawko commented on June 15, 2024

Got it. I just converted the downloaded matrices and I think it worked. Yes, so I missed entirely the specification for %%AMGX header. I think I just mixed up what's actual header and what's a comment. The example made it clear.

I have two quick questions. I am not sure if I understand block size. When do I use block size other than 1, 1? Also, it seems that block_dimx=1 is the only one supported according to the docs for distributed read. Should I just keep it 1, 1 for all matrices I download or generate?

from amgx.

marsaev avatar marsaev commented on June 15, 2024

I just converted the downloaded matrices and I think it worked.

Easiest way to check - see initial residual and compare it with some ground truth, for example by calculating it in matlab.

When do I use block size other than 1, 1?

Typically it can be used when you solve different equations on the same grid - thus equations are coupled and matrix has the block structure (i.e. pressure-velocity equations in CFD). It save memory for CSR storage and computational time when working on CSR structure (i.e. aggregation, coloring).

it seems that block_dimx=1 is the only one supported according to the docs for distributed read.

There are few routines for distributed data read/upload, some of them does work with blocksize=1x1 only.

Should I just keep it 1, 1 for all matrices I download or generate?

It's safe to always use 1x1. If you have some additional information about the problem - you might try block solvers.

from amgx.

robertsawko avatar robertsawko commented on June 15, 2024

Great. Thanks for a reply. It all makes sense to me now.

from amgx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.