TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Terme_Source_Constituant.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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_Constituant.h>
17#include <Schema_Temps_base.h>
18#include <Probleme_base.h>
19
20/*! @brief Lit le terme de puissance a partir d'un flot d'entree.
21 *
22 * Lit uniquement un champ donne representant la_puissance.
23 *
24 * @param (Entree& is) un flot d'entree
25 */
27{
28 Cerr << "Lecture du Champ Source pour le terme source du/des constituants" << finl;
29 is >> la_source_constituant;
30}
31
33{
34 colw_ = -1;
35 for (int i = 0; i < inco.nb_comp(); ++i)
36 colw_ = std::max(colw_, inco.noms_compo()[i].longueur());
37 return colw_;
38}
39
40void Terme_Source_Constituant::ouvrir_fichier(const Equation_base& eq, const Nom& out, const Nom& qsj, const Nom& description, SFichier& os,const Nom& type, const int flag) const
41{
42 // flag nul on n'ouvre pas le fichier
43 if (flag==0)
44 return ;
45
46 const Probleme_base& pb = eq.probleme();
47 const Schema_Temps_base& sch = pb.schema_temps();
48
49 Nom nomfichier(out);
50 if (type!="") nomfichier+=(Nom)"_"+type;
51 nomfichier+=".out";
52
53 // On cree le fichier a la premiere impression avec l'en tete
54 const int wcol = std::max(colw_, sch.wcol());
55 os.set_col_width(wcol);
56 if (sch.nb_impr()==1 && !pb.reprise_effectuee())
57 {
58 const int gnuplot_header = sch.gnuplot_header();
59 os.ouvrir(nomfichier);
60 SFichier& fic=os;
61 fic << (Nom)"# Printing of the source term " + qsj + " of the equation "+ eq.que_suis_je() +" of the problem "+ eq.probleme().le_nom() << finl;
62 fic << "# " << description << finl;
63 if (!gnuplot_header) fic << "#";
64 os.set_col_width(wcol - !gnuplot_header);
65 fic.add_col("Time");
66 os.set_col_width(wcol);
67 for (int i = 0; i < eq.inconnue().nb_comp(); ++i)
68 fic.add_col(eq.inconnue().noms_compo()[i].getChar());
69 fic << finl;
70 }
71 // Sinon on l'ouvre
72 else
73 {
74 os.ouvrir(nomfichier,ios::app);
75 }
76 os.precision(sch.precision_impr());
77 os.setf(ios::scientific);
78}
Classe Champ_Inc_base.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Equation_base Le role d'une equation est le calcul d'un ou plusieurs champs....
virtual const Champ_Inc_base & inconnue() const =0
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
virtual int nb_comp() const
Definition Field_base.h:56
const Noms & noms_compo() const
Renvoie le tableau des noms des composantes du champ.
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Probleme_U.h:109
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
bool & reprise_effectuee()
const Schema_Temps_base & schema_temps() const
Renvoie le schema en temps associe au probleme.
Cette classe est a la classe C++ ofstream ce que la classe Sortie est a la classe C++ ostream Elle re...
Definition SFichier.h:27
class Schema_Temps_base
int nb_impr() const
Renvoie le nombre d'impressions effectuees.
virtual int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out)
void precision(int pre) override
void setf(IOS_FORMAT code) override
void set_col_width(int w)
Definition Sortie.h:66
virtual int add_col(const double ob)
Definition Sortie.cpp:83
void lire_donnees(Entree &)
Lit le terme de puissance a partir d'un flot d'entree.
int completer(const Champ_Inc_base &inco)
void ouvrir_fichier(const Equation_base &eq, const Nom &out, const Nom &qsj, const Nom &description, SFichier &os, const Nom &type, const int flag) const