TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Solv_GCP.h
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#ifndef Solv_GCP_included
17#define Solv_GCP_included
18
19#include <Matrice_SuperMorse.h>
20#include <Matrice_Morse_Sym.h>
21#include <solv_iteratif.h>
22#include <Precond_base.h>
23#include <TRUST_Deriv.h>
24
26{
27 Declare_instanciable_sans_constructeur(Solv_GCP);
28public:
29 Solv_GCP();
30 int resoudre_systeme(const Matrice_Base&, const DoubleVect&, DoubleVect&) override;
31 int resoudre_systeme(const Matrice_Base&, const DoubleVect&, DoubleVect&, int) override;
32 inline const OWN_PTR(Precond_base)& get_precond() const { return le_precond_; }
33 inline OWN_PTR(Precond_base)& get_precond() { return le_precond_; }
34 inline void set_precond(const OWN_PTR(Precond_base)& pre) { le_precond_ = pre; }
35 void reinit() override;
37 {
38 return !le_precond_ || le_precond_->supporte_matrice_morse_sym();
39 }
40 // GCP does not need that b has an updated virtual space...
41 int get_flag_updated_input() const override { return 0; }
42
43protected:
44 void prepare_data(const Matrice_Base& matrice, const DoubleVect& secmem, DoubleVect& solution);
45 int resoudre_(const Matrice_Base&, const DoubleVect&, DoubleVect&, int);
46
47 bool optimized_ = false;
48 OWN_PTR(Precond_base) le_precond_;
49 // Data file parameter: should we apply global diagonal preconditioning?
50 // In that case, the matrix is copied and multiplied on the left and right by 1/sqrt(diagonal)
51 // and the right-hand side and solution are similarly scaled.
52 // (Warning: this changes the inner product metric and thus the interpretation of the threshold):
53 // A * X = B
54 // <=> D * A * X = D * B (with D = 1 / sqrt(diagonal))
55 // <=> (D * A * D) * Y = D * B, and X = D * Y
56 // Property: the diagonal entries of D * A * D are equal to 1
57 bool precond_diag_ = false;
58 // A vector with virtual items
60 // Four vectors without virtual items (one could add virtual spaces to all vectors,
61 // but this saves space in the cache).
62 DoubleVect resu_;
63 DoubleVect residu_;
64 // tmp_p_ points to the same memory region as tmp_p_avec_items_virt_
65 // (this alias is created because vector operations check that
66 // sizes and parallel structures are identical,
67 // e.g. for the preconditioner...)
68 DoubleVect tmp_p_;
69 DoubleVect tmp_solution_;
70 // Matrix of real-real coefficients
72 // Matrix of real-virtual coefficients (storage without empty rows)
74 // Memory block holding temporary vectors and possibly matrices
75 // (do not read from it directly: it also contains integers!)
76 // Using double to ensure correct memory alignment
77 ArrOfDouble tmp_data_block_;
78 // Renumbering table between the RHS and the temporary vectors
79 // (removal of shared and unused virtual items)
80 IntVect renum_;
81 // If diagonal preconditioning is to be applied,
82 // inverse of the square root of the diagonal coefficients of the matrix
83 // Warning: the virtual space of this vector is updated because it is needed
84 // for D*A*D
85 DoubleVect inv_sqrt_diag_;
86 int reinit_ = 0; // 0=> nothing ready, 1=> memory allocated, matrix coeffs to copy, 2=> ok
87 int nb_it_max_ = -1;
88};
89
90#endif /* Solv_GCP_included */
Matrice_Base class - Base class of the matrix hierarchy.
Matrice_Morse_Sym class - Represents a sparse symmetric matrix M stored in Morse format.
: Matrix with an even sparser storage than Matrice_Morse: only non-empty rows are stored (saving on t...
int get_flag_updated_input() const override
Definition Solv_GCP.h:41
DoubleVect resu_
Definition Solv_GCP.h:62
bool optimized_
Definition Solv_GCP.h:47
DoubleVect tmp_solution_
Definition Solv_GCP.h:69
int nb_it_max_
Definition Solv_GCP.h:87
DoubleVect residu_
Definition Solv_GCP.h:63
void set_precond(const OWN_PTR(Precond_base)&pre)
Definition Solv_GCP.h:34
ArrOfDouble tmp_data_block_
Definition Solv_GCP.h:77
DoubleVect tmp_p_
Definition Solv_GCP.h:68
void reinit() override
Definition Solv_GCP.cpp:129
bool precond_diag_
Definition Solv_GCP.h:57
int supporte_matrice_morse_sym() override
Definition Solv_GCP.h:36
DoubleVect inv_sqrt_diag_
Definition Solv_GCP.h:85
OWN_PTR(Precond_base) le_precond_
Matrice_SuperMorse tmp_mat_virt_
Definition Solv_GCP.h:73
IntVect renum_
Definition Solv_GCP.h:80
int resoudre_(const Matrice_Base &, const DoubleVect &, DoubleVect &, int)
Definition Solv_GCP.cpp:422
int reinit_
Definition Solv_GCP.h:86
int resoudre_systeme(const Matrice_Base &, const DoubleVect &, DoubleVect &) override
Definition Solv_GCP.cpp:111
const OWN_PTR(Precond_base) &get_precond() const
Definition Solv_GCP.h:32
OWN_PTR(Precond_base) &get_precond()
Definition Solv_GCP.h:33
void prepare_data(const Matrice_Base &matrice, const DoubleVect &secmem, DoubleVect &solution)
Definition Solv_GCP.cpp:138
DoubleVect tmp_p_avec_items_virt_
Definition Solv_GCP.h:59
Matrice_Morse_Sym tmp_mat_
Definition Solv_GCP.h:71