TrioCFD 1.9.9_beta
TrioCFD documentation
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 Reads the power term from an input stream.
21 *
22 * Reads only a given field representing the power.
23 *
24 * @param is an input stream
25 */
27{
28 Cerr << "Reading the source field for the constituent(s) source term" << 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 // null flag, file is not opened
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 // Create the file at the first print with the header
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 // Otherwise open it
72 else
73 {
74 os.ouvrir(nomfichier,ios::app);
75 }
76 os.precision(sch.precision_impr());
77 os.setf(ios::scientific);
78}
Class Champ_Inc_base.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Equation_base The role of an equation is the calculation of one or more fields....
virtual const Champ_Inc_base & inconnue() const =0
Probleme_base & probleme()
Returns the problem associated with the equation.
virtual int nb_comp() const
Definition Field_base.h:56
const Noms & noms_compo() const
Returns the array of names of the field components.
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Probleme_U.h:109
class Probleme_base It is a Probleme_U that is not a coupling.
bool & reprise_effectuee()
const Schema_Temps_base & schema_temps() const
Returns the time scheme associated with the problem.
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
Definition SFichier.h:29
class Schema_Temps_base
int nb_impr() const
Returns the number of outputs performed.
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 &)
Reads the power term from an input stream.
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