TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Champ_Morceaux.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 <Champ_Morceaux.h>
17#include <Discretisation_base.h>
18#include <Champ_Fonc_MED.h>
19#include <Champ_Uniforme.h>
20#include <Probleme_base.h>
21#include <Domaine_dis_base.h>
22#include <Param.h>
23
24Implemente_instanciable(Champ_Morceaux,"Champ_Morceaux",Champ_Fonc_P0_base);
25// XD champ_morceaux champ_don_base champ_morceaux NO_BRACE Field defined by subfields on a list of subdomains. Each
26// XD_CONT field must be defined on the whole domain.
27// XD attr problem_name ref_Pb_base problem_name REQ Name of the problem.
28// XD attr data bloc_lecture data REQ { Defaut field_def sous_domaine_1 field_1 ... sous_domaine_i field_i } By default,
29// XD_CONT the field field_def is assigned to the field. It takes the sous_domaine_i identifier Sous_Domaine (sub_area)
30// XD_CONT type object field, field_i. Sous_Domaine (sub_area) type objects must have been previously defined if the
31// XD_CONT operator wishes to use a champ_morceaux type object.
32
33Sortie& Champ_Morceaux::printOn(Sortie& os) const { return os; }
34
36{
37 nb_compo_ = -1;
38 // first keywords : domain and components
39 Nom nom;
40 is >> nom;
41 pb_ = ref_cast(Probleme_base, Interprete::objet(nom));
42 associer_domaine_dis_base(pb_->domaine_dis());
43 IntTrav filled; //to check if subdomains cover the whole domain
44 pb_->domaine().creer_tableau_elements(filled);
45 //loop over subdomains
46 is >> nom;
47 if (nom != "{")
48 Process::exit(que_suis_je() + " : { expected instead of " + nom);
49 for (is >> nom; nom != "}"; is >> nom)
50 {
51 if (nom == "default") nom = "defaut";
52 if (nom != "defaut")
53 {
54 const Sous_Domaine& sdom = pb_->domaine().ss_domaine(nom);
55 for (int i = 0; i < sdom.nb_elem_tot(); i++)
56 filled(sdom(i)) = 1;
57 }
58 if (field_.count(nom.getString()))
59 Process::exit(que_suis_je() + " : the sudomain " + nom + "has been specified twice!");
60 is >> field_[nom.getString()];
61 if (nb_compo_ < 0)
62 nb_compo_ = field_[nom.getString()]->nb_comp();
63 else if (field_[nom.getString()]->nb_comp() != nb_compo_)
64 Process::exit(que_suis_je() + " : the field on " + nom + " has " + Nom(field_[nom.getString()]->nb_comp()) + " components instead of " + Nom(nb_compo_) + " !");
65 }
66 //either check that there no missing elements or add them to the "default_vals" list
67 if (!field_.count("defaut") && mp_min_vect(filled) == 0)
68 Process::exit(que_suis_je() + " : some pieces of the field are missing!");
69 else for (int e = 0; e < pb_->domaine().nb_elem(); e++)
70 if (!filled(e))
71 default_vals_.append_line(e);
72 valeurs_.resize(0, nb_compo_);
73 noms_compo_.dimensionner(nb_compo_);
74 pb_->domaine().creer_tableau_elements(valeurs_);
75
76 // store xp in each sub-zone (some fields need positions for valeur_aux, ex : champ_fonc_xyz)
77 const DoubleTab& xp_dom = ref_cast(Domaine_VF, pb_->domaine_dis()).xp();
78 for (auto &&kv : field_)
79 {
80 const IntVect& elems = kv.first == "defaut" ? default_vals_ : pb_->domaine().ss_domaine(kv.first).les_elems();
81 xp_ssz_[kv.first].resize(elems.size(), dimension);
82 for (int i = 0; i < elems.size(); i++)
83 for (int d = 0; d < dimension; d++)
84 xp_ssz_[kv.first](i, d) = xp_dom(elems(i), d);
85 }
86
87 return is;
88}
89
91{
92 for (auto &&kv : field_)
93 {
94 kv.second->mettre_a_jour(temps);
95 const IntVect& elems = kv.first == "defaut" ? default_vals_ : pb_->domaine().ss_domaine(kv.first).les_elems();
96 DoubleTrav vals(elems.size(), nb_compo_);
97
98 kv.second->valeur_aux_elems(xp_ssz_[kv.first], elems, vals);
99 for (int i = 0; i < elems.size(); i++)
100 for (int e = elems(i), n = 0; n < nb_compo_; n++)
101 valeurs_(e, n) = vals(i, n);
102 }
103 valeurs_.echange_espace_virtuel();
104}
105
107{
108 int res = 1;
109 for (auto &&kv : field_)
110 res &= kv.second->initialiser(t);
111 mettre_a_jour(t);
112 return res;
113}
114
115double Champ_Morceaux::changer_temps(const double t)
116{
117 for (auto &&kv : field_)
118 kv.second->changer_temps(t);
119 return t;
120}
121
123{
124 for (auto &&kv : field_)
125 kv.second->fixer_unite(unit);
126 return unit;
127}
128
129const Nom& Champ_Morceaux::fixer_unite(int i, const Nom& unit)
130{
131 for (auto &&kv : field_)
132 kv.second->fixer_unite(i, unit);
133 return unit;
134}
135
137{
139 for (auto &&kv : field_)
140 kv.second->associer_domaine_dis_base(zdb);
141}
DoubleTab valeurs_
void associer_domaine_dis_base(const Domaine_dis_base &zdb) override
const Nom & fixer_unite(const Nom &unit) override
Specifie l'unite d'un champ scalaire ou dont toutes les composantes ont la meme unite.
void mettre_a_jour(double) override
Mise a jour en temps du champ.
double changer_temps(const double t) override
Fixe le temps auquel se situe le champ.
int initialiser(const double t) override
NE FAIT RIEN.
virtual void associer_domaine_dis_base(const Domaine_dis_base &)
const Sous_Domaine_t & ss_domaine(int i) const
Definition Domaine.h:290
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Noms noms_compo_
Definition Field_base.h:94
int nb_compo_
Definition Field_base.h:95
static Objet_U & objet(const Nom &)
Voir Interprete_bloc::objet_global() BM: la classe Interprete n'est pas le meilleur endroit pour cett...
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
static int dimension
Definition Objet_U.h:99
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
int_t nb_elem_tot() const
Domaine_t & domaine()
_SIZE_ size() const
Definition TRUSTVect.tpp:45
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91