TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Solv_AMGX.h
1/****************************************************************************
2* Copyright (c) 2025, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Solv_AMGX_included
17#define Solv_AMGX_included
18
19#include <Solv_Petsc.h>
20
21#ifdef TRUST_USE_CUDA
22#include <AmgXSolver.hpp>
23#include <amgx_c.h>
24#endif
25
26class Solv_AMGX : public Solv_Petsc
27{
28 Declare_instanciable_sans_constructeur(Solv_AMGX);
29public:
30 inline Solv_AMGX()
31 {
32 amgx_=true;
33 };
34protected :
35#ifdef PETSCKSP_H
36#ifdef TRUST_USE_CUDA
37 void Create_objects(const Matrice_Morse&, int blocksize) override;
38 void Create_vectors(const DoubleVect&) override;
39 void Update_vectors(const DoubleVect& secmem, DoubleVect& solution) override;
40 void Update_solution(DoubleVect& solution) override;
41 void Update_matrix(Mat&, const Matrice_Morse&) override;
42 bool detect_new_stencil(const Matrice_Morse&) override;
43 int solve(ArrOfDouble& residual) override;
44 int nbiter(ArrOfDouble& residual);
45 void initialize();
46 void finalize() override
47 {
49 {
50 SolveurAmgX_.finalize();
51 amgx_initialized_ = false;
52 }
53 }
54 AmgXSolver SolveurAmgX_; // Instance de AmgXWrapper
55
56 PetscErrorCode petscToCSR(Mat& A, Vec& lhs_petsc, Vec& rhs_petsc);
57 PetscInt nRowsLocal, nRowsGlobal, nNz;
58 Mat localA = nullptr;
59 const PetscInt *colIndices = nullptr, *rowOffsets = nullptr;
60 PetscScalar *values;
61#endif
62#endif
63};
64#endif
65
66
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
void Update_solution(DoubleVect &x)
bool amgx_initialized_
Definition Solv_Petsc.h:205