TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Matrice_Petsc.h
1/****************************************************************************
2* Copyright (c) 2024, 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 Matrice_Petsc_included
17#define Matrice_Petsc_included
18
19#include <petsc_for_kernel.h>
20#include <Matrice_Base.h>
21
23{
24
25 Declare_instanciable(Matrice_Petsc);
26
27public:
28
29 int ordre() const override
30 {
31#ifdef PETSCKSP_H
32 PetscInt m,n;
33 MatGetLocalSize(Mat_, &m, &n);
34 return m == n ? (int)m : 0;
35#else
36 Cerr << "Matrice_Petsc non disponible." << finl;
38 return 0;
39#endif
40 }
41
42 int nb_lignes() const override
43 {
44#ifdef PETSCKSP_H
45 PetscInt m,n;
46 MatGetLocalSize(Mat_, &m, &n);
47 return (int)m;
48#else
49 Cerr << "Matrice_Petsc non disponible." << finl;
51 return 0;
52#endif
53 }
54
55 int nb_colonnes() const override
56 {
57#ifdef PETSCKSP_H
58 PetscInt m,n;
59 MatGetLocalSize(Mat_, &m, &n);
60 return (int)n;
61#else
62 Cerr << "Matrice_Petsc non disponible." << finl;
64 return 0;
65#endif
66 }
67
68 void scale(const double x) override
69 {
70 Cerr << "ToDo" << finl;
71 Process::exit(-1);
72 }
73
74 DoubleVect& ajouter_multvect_(const DoubleVect& x, DoubleVect& r) const override
75 {
76 Cerr << "ToDo" << finl;
77 Process::exit(-1);
78 return r;
79 }
80
81 DoubleVect& ajouter_multvectT_(const DoubleVect& x, DoubleVect& r) const override
82 {
83 Cerr << "ToDo" << finl;
84 Process::exit(-1);
85 return r;
86 }
87
88 DoubleTab& ajouter_multTab_(const DoubleTab& x, DoubleTab& r) const override
89 {
90 Cerr << "ToDo" << finl;
91 Process::exit(-1);
92 return r;
93 }
94
95#ifdef PETSCKSP_H
96 inline const Mat& getMat() const
97 {
98 return Mat_;
99 }
100
101private :
102 Mat Mat_;
103#endif
104};
105#endif
Classe Matrice_Base Classe de base de la hierarchie des matrices.
DoubleTab & ajouter_multTab_(const DoubleTab &x, DoubleTab &r) const override
int nb_lignes() const override
Return local number of lines (=size on the current proc).
DoubleVect & ajouter_multvect_(const DoubleVect &x, DoubleVect &r) const override
DoubleVect & ajouter_multvectT_(const DoubleVect &x, DoubleVect &r) const override
void scale(const double x) override
int ordre() const override
If square matrix, returns number of lines, otherwise 0.
int nb_colonnes() const override
Return local number of columns (=size on the current proc).
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455