BTW, as I've said in comments in header - AmgX can actually be used in CPU 
too, so if you'd be willing to apply AMG to CPU execution, it'll require 
changing a single enum` AMGX_Mode::AMGX_mode_dDDI`//<-replace `dDDI` to 
`hDDI` to put execution on CPU.
On Sunday, November 3, 2024 at 10:47:24 PM UTC Maksym Riabov wrote:

> Hello Chrono,
> After this post <https://groups.google.com/g/projectchrono/c/of58DygfuAA>, 
> I've actually sat down to implement AmgX in chrono. It seems easier than I 
> thought... Or at least I think.
>
> This is `Setup` from solver:
>
> ```
> bool ChSolverAmgX::Setup(ChSystemDescriptor& sysd) {
>     // code assuming one AmgX per machine although it may well not be in 
> the case of multiple instances of Chrono
>     // running in paralel
>     AMGX_SAFE_CALL(AMGX_initialize());
>     // also can be created from a string. You know solvers better, so 
> config up to you.
>     AMGX_SAFE_CALL(AMGX_config_create_from_file(&cfg, 
> "path_to_config_here"))
>
>     AMGX_resources_create_simple(&rsrc, cfg);
>     AMGX_matrix_create(&A, rsrc, mode);  // the code seems to never 
> create the matrices first.
>     AMGX_vector_create(&x, rsrc, mode);
>     AMGX_vector_create(&b, rsrc, mode);
>     AMGX_solver_create(&solver, rsrc, mode, cfg);
>
>     // sysd.WriteMatrixMtx("where_to_read_matrix_from.", "prefix_sample_", 
> true);
>     // AMGX_read_system(A, b, x, "prefix_sample_.mtx");// this is if we 
> want store and read file.
>
>     ChSparseMatrix Z;
>     sysd.BuildSystemMatrix(&Z, &m_rhs);
>     AMGX_matrix_upload_all(A, Z., Z.nonZeros(), Z.outerSize(), Z.innerSize(), 
> Z.outerIndexPtr(), Z.innerIndexPtr(),
>                            &Z.data(),
>                            Z.diagonal().data());  // I'm not dead sure 
> about block_dimx, block_dimy...
>
>     AMGX_solver_setup(solver, A);  // bulk of the matrix setup
>
>     return true;
> } ``` The AMGX_matrix_upload_all command is basically to put chrono 
> vectors of data to amgx. So it needs that data for solution. It requires 
> `n`, `block_dimx` and `block_dimy` parameters: [image: image (4).png]
>
> I don't 100% know how solvers work on the inside, so where can I take 
> these values? I understand that these values are arising from bodies and 
> constraints, but I'm not 100% sure. What do I need to input there? 
> Cheers, Maksym Riabov P.S. I'll add the two files that serve as logic, so 
> you may take a look - maybe you'd say something.
>

-- 
You received this message because you are subscribed to the Google Groups 
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/projectchrono/21ac9cb8-e5db-4642-bdc3-97e60d391839n%40googlegroups.com.

Reply via email to