TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Terme_Source_Decroissance_Radioactive_Elem_PolyMAC_CDO.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 <Terme_Source_Decroissance_Radioactive_Elem_PolyMAC_CDO.h>
17#include <Domaine_VF.h>
18
19#include <Equation_base.h>
20#include <Synonyme_info.h>
21#include <Probleme_base.h>
22#include <Matrix_tools.h>
23#include <Array_tools.h>
24
25Implemente_instanciable(Terme_Source_Decroissance_Radioactive_Elem_PolyMAC_CDO, "Decroissance_Radioactive_Elem_PolyMAC_CDO|Decroissance_Radioactive_Elem_PolyMAC_HFV", Source_base);
26Add_synonym(Terme_Source_Decroissance_Radioactive_Elem_PolyMAC_CDO, "Decroissance_Radioactive_Elem_PolyMAC_MPFA");
27
28Add_synonym(Terme_Source_Decroissance_Radioactive_Elem_PolyMAC_CDO, "radioactive_decay_Elem_PolyMAC_HFV");
29Add_synonym(Terme_Source_Decroissance_Radioactive_Elem_PolyMAC_CDO, "radioactive_decay_Elem_PolyMAC_MPFA");
30Add_synonym(Terme_Source_Decroissance_Radioactive_Elem_PolyMAC_CDO, "radioactive_decay_Elem_PolyMAC_CDO");
31// XD radioactive_decay source_base radioactive_decay NO_BRACE Radioactive decay source term of the form $-\lambda_i
32// XD_CONT c_i$, where $0 \leq i \leq N$, N is the number of component of the constituent, $c_i$ and $\lambda_i$ are the
33// XD_CONT concentration and the decay constant of the i-th component of the constituant.
34// XD attr val list val REQ n is the number of decay constants to read (int), and val1, val2... are the decay constants
35// XD_CONT (double)
36
38
40{
41 double lambda_tmp;
42 int nb_groupes;
43 s >> nb_groupes;
44 Cerr << "Nombre de groupes a lire : " << nb_groupes << finl;
45 for (int i = 0; i < nb_groupes; i++)
46 {
47 s >> lambda_tmp;
48 Cerr << "lambda lu : " << lambda_tmp << finl;
49 lambda_.push_back(lambda_tmp);
50 }
51
52 const int N = equation().inconnue().valeurs().line_size(), ng = (int)lambda_.size();
53 if (N != ng)
54 {
55 Cerr << "Terme_Source_Decroissance_Radioactive_Elem_PolyMAC_CDO : inconsistency between the number of radioactive decay constants ( " << ng
56 << " ) and the number of components of the unknown of the equation ( " << N << " )" << finl;
58 }
59 return s ;
60}
61
62void Terme_Source_Decroissance_Radioactive_Elem_PolyMAC_CDO::dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl) const
63{
64 const DoubleTab& inco = equation().inconnue().valeurs();
65 const int ne = equation().domaine_dis().nb_elem(), N = inco.line_size();
66 std::string nom_inco = equation().inconnue().le_nom().getString();
67
68 for (auto &&n_m : matrices)
69 if (n_m.first == nom_inco)
70 {
71 Matrice_Morse& mat = *n_m.second, mat2;
72 Stencil sten(0, 2);
73
74 for (int e = 0; e < ne; e++)
75 for (int n = 0; n < N; n++)
76 sten.append_line(N * e + n, N * e + n);
77 tableau_trier_retirer_doublons(sten);
78 Matrix_tools::allocate_morse_matrix(inco.size_totale(), equation().probleme().get_champ(n_m.first.c_str()).valeurs().size_totale(), sten, mat2);
79 mat.nb_colonnes() ? mat += mat2 : mat = mat2;
80 }
81}
82
83void Terme_Source_Decroissance_Radioactive_Elem_PolyMAC_CDO::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
84{
85 const Domaine_VF& domaine = ref_cast(Domaine_VF, equation().domaine_dis());
86 const DoubleVect& pe = equation().milieu().porosite_elem(), &ve = domaine.volumes();
87 const DoubleTab& c = equation().inconnue().valeurs();
88 std::string nom_inco = equation().inconnue().le_nom().getString();
89 Matrice_Morse *Mc = matrices.count(nom_inco) ? matrices.at(nom_inco) : nullptr;
90 const int N = c.line_size(), ne = domaine.nb_elem();
91
92 for (int e = 0; e < ne; e++)
93 for (int l = 0; l < N; l++)
94 {
95 const double fac = pe(e) * ve(e) * lambda_[l];
96 secmem(e, l) -= fac * c(e, l);
97 if (Mc)
98 (*Mc)(N * e + l, N * e + l) += fac;
99 }
100}
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
virtual DoubleTab & valeurs()=0
class Domaine_VF
Definition Domaine_VF.h:44
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Milieu_base & milieu() const =0
virtual const Champ_Inc_base & inconnue() const =0
Domaine_dis_base & domaine_dis()
Renvoie le domaine discretise associe a l'equation.
const Nom & le_nom() const override
Renvoie le nom du champ.
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
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)
DoubleVect & porosite_elem()
Definition Milieu_base.h:58
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
const std::string & getString() const
Definition Nom.h:92
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
classe Source_base Un objet Source_base est un terme apparaissant au second membre d'une
Definition Source_base.h:42
const Champ_base & get_champ(const Motcle &nom) const override
void append_line(_TYPE_)
Definition TRUSTTab.tpp:213
_SIZE_ size_totale() const
Definition TRUSTVect.tpp:61
int line_size() const
Definition TRUSTVect.tpp:67
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl={}) const override