TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Champ_Composite.cpp
1/****************************************************************************
2* Copyright (c) 2023, 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_Composite.h>
17#include <Motcle.h>
18
19Implemente_instanciable(Champ_Composite,"Champ_Composite",Champ_Don_base);
20// XD champ_composite champ_don_base champ_composite NO_BRACE Composite field. Used in multiphase problems to associate
21// XD_CONT data to each phase.
22// XD attr dim entier dim REQ Number of field components.
23// XD attr bloc bloc_lecture bloc REQ Values Various pieces of the field, defined per phase. Part 1 goes to phase 1,
24// XD_CONT etc...
25
27
29{
30 nommer(que_suis_je()); // pour printOn
31
32 Motcle motlu, acc_ouv("{"), acc_fer("}");
33 is >> dim_;
34 assert (dim_ > 0);
35 z_fld_.resize(dim_);
36
37 is >> motlu;
38 if (motlu != acc_ouv)
39 {
40 Cerr << "Error in the readOn of Champ_Composite ! We expected a { and not " << motlu << " ! Call the 911 !" << finl;
42 }
43
44 for (int i = 0; i < dim_; i++) is >> z_fld_[i];
45
46 is >> motlu;
47 if (motlu != acc_fer)
48 {
49 Cerr << "Error in the readOn of Champ_Composite ! We expected a } and not " << motlu << " ! Call the 911 !" << finl;
51 }
52
53 // XXX : On verifie qu'on a lu les memes types de champs ...
54 for (int i = 1; i < dim_ ; i++)
55 if (z_fld_[i]->que_suis_je() != z_fld_[0]->que_suis_je())
56 {
57 Cerr << "Champ_Composite should define the same field types !" << finl;
59 }
60
61 // pour la methode valeurs()
62 const int ncompo = z_fld_[0]->nb_comp() * dim_, nnodes = z_fld_[0]->valeurs().dimension_tot(0);
63 fixer_nb_comp(ncompo);
66 return is;
67}
68
69/*
70 * On stock comme ca : X X X ... Y Y Y ... Z Z Z ...
71 */
73{
74 for (int nbp = 0; nbp < dim_; nbp++)
75 for (int i = 0; i < nb_valeurs_nodales(); i++)
76 for (int j = 0; j < z_fld_[0]->nb_comp(); j++)
77 valeurs_(i, nbp + j * dim_) = z_fld_[nbp]->valeurs()(i, j);
78}
79
81{
82 for (auto &fld : z_fld_)
83 fld->mettre_a_jour(tps);
84}
85
86DoubleTab& Champ_Composite::valeur_aux(const DoubleTab& xv, DoubleTab& tab_valeurs) const
87{
88 for (int nbp = 0; nbp < dim_; nbp++)
89 {
90 DoubleTab tmp(tab_valeurs.dimension_tot(0), tab_valeurs.line_size() / dim_);
91 z_fld_[nbp]->valeur_aux(xv,tmp);
92 assert (tab_valeurs.dimension_tot(0) == tmp.dimension_tot(0));
93 assert (tmp.line_size() * dim_ == tab_valeurs.line_size());
94 for (int i = 0; i < tab_valeurs.dimension_tot(0); i++)
95 for (int j = 0; j < tmp.line_size(); j++)
96 tab_valeurs(i, nbp + j * dim_) = tmp(i,j);
97 }
98 tab_valeurs.echange_espace_virtuel();
99
100 return tab_valeurs;
101}
DoubleTab & valeur_aux(const DoubleTab &, DoubleTab &tab_valeurs) const override
Provoque une erreur ! Doit etre surchargee par les classes derivees.
std::vector< OWN_PTR(Champ_Don_base)> z_fld_
void mettre_a_jour(double tps) override
mettre_a_jour de la classe de base Champ_base :ne fait rien !
classe Champ_Don_base classe de base des Champs donnes (non calcules)
int fixer_nb_valeurs_nodales(int nb_noeuds) override
Fixe le nombre de degres de liberte par composante.
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
int nb_valeurs_nodales() const override
Renvoie le nombre de degre de liberte par composante: le nombre de noeuds.
DoubleTab valeurs_
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual void fixer_nb_comp(int i)
Fixe le nombre de composantes du champ.
void nommer(const Nom &) override
Donne un nom au champ.
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
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
int line_size() const
Definition TRUSTVect.tpp:67
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")