TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Sources_Multiphase_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 <Sources_Multiphase_base.h>
17
18#include <Probleme_base.h>
19#include <Matrix_tools.h>
20
21Implemente_base(Sources_Multiphase_base, "Sources_Multiphase_base", Source_base);
22Sortie& Sources_Multiphase_base::printOn(Sortie& os) const { return os; }
24
25/*! @brief Allocates diagonal stencils in the given matrices for field names
26 * listed in diagonal_fields (and optionally "pression" with its
27 * special index mapping).
28 */
29void Sources_Multiphase_base::dimensionner_blocs_diagonal(matrices_t matrices, const Probleme_base& pb, int ne, int ne_tot, int Nk,
30 const std::set<std::string>& diagonal_fields, bool handle_pression)
31{
32 for (auto &&n_m : matrices)
33 {
34 bool is_diag = diagonal_fields.count(n_m.first);
35 bool is_pression = handle_pression && (n_m.first == "pression");
36 if (!is_diag && !is_pression) continue;
37
38 Matrice_Morse& mat = *n_m.second;
39 Matrice_Morse mat2;
40 const DoubleTab& dep = pb.get_champ(n_m.first.c_str()).valeurs();
41 const int nc = dep.dimension_tot(0);
42 const int M = dep.line_size();
43 Stencil sten(0, 2);
44
45 if (is_diag)
46 for (int e = 0; e < ne; e++)
47 for (int n = 0; n < Nk; n++)
48 if (n < M)
49 sten.append_line(Nk * e + n, M * e + n);
50
51 if (is_pression)
52 for (int e = 0; e < ne; e++)
53 for (int n = 0, m = 0; n < Nk; n++, m += (M > 1))
54 sten.append_line(Nk * e + n, M * e + m);
55
56 Matrix_tools::allocate_morse_matrix(Nk * ne_tot, M * nc, sten, mat2);
57 mat.nb_colonnes() ? mat += mat2 : mat = mat2;
58 }
59}
virtual DoubleTab & valeurs()=0
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
int nb_colonnes() const override
Return local number of columns (=size on the current proc).
static void allocate_morse_matrix(const int nb_lines, const int nb_columns, const Stencil &stencil, Matrice_Morse &matrix, const bool &attach_stencil_to_matrix=false)
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
class Probleme_base It is a Probleme_U that is not a coupling.
const Champ_base & get_champ(const Motcle &nom) const override
Base class for output streams.
Definition Sortie.h:52
Source_base A Source_base object is a term appearing on the right-hand side of an.
Definition Source_base.h:42
static void dimensionner_blocs_diagonal(matrices_t matrices, const Probleme_base &pb, int ne, int ne_tot, int Nk, const std::set< std::string > &diagonal_fields, bool handle_pression)
Allocates diagonal stencils in the given matrices for field names listed in diagonal_fields (and opti...
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
void append_line(_TYPE_)
Definition TRUSTTab.tpp:213
int line_size() const
Definition TRUSTVect.tpp:67