TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Matrice_Base.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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#include <Matrice_Base.h>
17#include <Matrice_Morse.h>
18#include <Matrice_Morse_Sym.h>
19#include <Matrix_tools.h>
20#include <Array_tools.h>
21
22Implemente_base(Matrice_Base,"Matrice_Base",Objet_U);
23
25printOn(Sortie& s ) const
26{
27 return s << que_suis_je() << finl;
28}
30readOn(Entree& s )
31{
32 return s ;
33}
34
35/*! @brief Friend function (outside the class) of the Matrice_Base class.
36 *
37 * Multiplication operator: returns (A*vect)
38 * Calls Matrice_base::multv(const DoubleVect&) on A.
39 *
40 * @param (Matrice_Base& A) the multiplying matrix
41 * @param (DoubleVect& vect) the vector to multiply
42 * @return (DoubleVect) the result vector of the operation
43 */
44DoubleVect operator * (const Matrice_Base& A, const DoubleVect& vect)
45{
46 DoubleVect r(A.nb_colonnes());
47 return A.multvect(vect, r);
48}
49
51{
52 Cerr << "Error in 'Matrice_Base::build_stencil( )"<<finl;
53 Cerr << " This method should be implemented in derived class." << finl;
54 Cerr << " Exiting..." << finl;
56}
57
59{
60 return stencil_.dimension( 0 );
61}
62
63void Matrice_Base::get_stencil( Stencil& stencil ) const
64{
65 Cerr << "Error in 'Matrice_Base::get_stencil( )':" << finl;
66 Cerr << " This method should be implemented in derived class." << finl;
67 Cerr << " Exiting..." << finl;
69}
70
71void Matrice_Base::get_symmetric_stencil( Stencil& stencil ) const
72{
73 Matrice_Morse tmp1;
75
76 Matrice_Morse_Sym tmp2( tmp1 );
77 tmp2.get_symmetric_stencil( stencil );
78}
79
81 StencilCoeffs& coefficients ) const
82{
83 Cerr << "Error in 'Matrice_Base::get_stencill_and_coefficients( )':" << finl;
84 Cerr << " This method should be implemented in derived class" << finl;
85 Cerr << " Exiting..." << finl;
87}
88
89void Matrice_Base::get_stencil_and_coeff_ptrs(Stencil& stencil, std::vector<const double *>& coeff_ptr) const
90{
91 Cerr << "Error in 'Matrice_Base::get_stencil_and_coeff_ptrs( )':" << finl;
92 Cerr << " This method should be implemented in derived class" << finl;
93 Cerr << " Exiting..." << finl;
95}
96
97
99 StencilCoeffs& coefficients ) const
100{
101 Matrice_Morse tmp1;
103
104 Matrice_Morse_Sym tmp2( tmp1 );
105 tmp2.get_symmetric_stencil_and_coefficients( stencil, coefficients );
106}
107
108void Matrice_Base::set_stencil( const Stencil& stencil )
109{
110 stencil_ = stencil ;
111 tableau_trier_retirer_doublons( stencil_ );
112 is_stencil_up_to_date_ = false ;
113}
114
119
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Matrice_Base class - Base class of the matrix hierarchy.
int get_stencil_size() const
void set_stencil(const Stencil &stencil)
virtual void get_symmetric_stencil(Stencil &stencil) const
virtual void get_stencil(Stencil &stencil) const
bool is_stencil_up_to_date_
virtual int nb_colonnes() const =0
Return local number of columns (=size on the current proc).
virtual DoubleVect & multvect(const DoubleVect &, DoubleVect &) const
Multiplication of a vector by the matrix.
Stencil stencil_
virtual void get_symmetric_stencil_and_coefficients(Stencil &stencil, StencilCoeffs &coefficients) const
virtual void get_stencil_and_coeff_ptrs(Stencil &stencil, std::vector< const double * > &coeff_ptr) const
virtual void get_stencil_and_coefficients(Stencil &stencil, StencilCoeffs &coefficients) const
virtual void build_stencil()
bool is_stencil_up_to_date() const
Matrice_Morse_Sym class - Represents a sparse symmetric matrix M stored in Morse format.
void get_symmetric_stencil_and_coefficients(Stencil &stencil, StencilCoeffs &coefficients) const override
void get_symmetric_stencil(Stencil &stencil) const override
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
static void convert_to_morse_matrix(const Matrice_Base &in, Matrice_Morse &out)
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52