TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Lec_Diffuse_base.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 <communications_array.h>
17#include <Lec_Diffuse_base.h>
18#include <Process.h>
19#include <assert.h>
20
21Implemente_base_sans_constructeur(Lec_Diffuse_base,"Lec_Diffuse_base",EFichier);
22
24{
25 throw;
26}
27
29{
30 throw;
31}
32
33/*! @brief ne fait rien (constructeur protege car c'est une classe de base)
34 *
35 */
37
38/*! @brief erreur
39 *
40 */
42{
43 Cerr << "Error in Lec_Diffuse_base & operator=(const Lec_Diffuse_base & is)" << finl;
45 return *this;
46}
47
48Entree& Lec_Diffuse_base::operator>>(int& ob) { return operator_template<int>(ob); }
49int Lec_Diffuse_base::get(int* ob, std::streamsize n) { return get_template<int>(ob, n); }
50
51Entree& Lec_Diffuse_base::operator>>(long& ob) { return operator_template<long>(ob); }
52int Lec_Diffuse_base::get(long* ob, std::streamsize n) { return get_template<long>(ob, n); }
53
54Entree& Lec_Diffuse_base::operator>>(long long& ob) { return operator_template<long long>(ob); }
55int Lec_Diffuse_base::get(long long* ob, std::streamsize n) { return get_template<long long>(ob, n); }
56
57Entree& Lec_Diffuse_base::operator>>(float& ob) { return operator_template<float>(ob); }
58int Lec_Diffuse_base::get(float* ob, std::streamsize n) { return get_template<float>(ob, n); }
59
60Entree& Lec_Diffuse_base::operator>>(double& ob) { return operator_template<double>(ob); }
61int Lec_Diffuse_base::get(double *ob, std::streamsize n) { return get_template<double>(ob, n); }
62
63int Lec_Diffuse_base::get(char *buf, std::streamsize bufsize)
64{
65 int l = -1;
67 {
69 assert(is.get_error_action() == ERROR_CONTINUE);
70 int ok = is.get(buf, bufsize);
71 if (ok)
72 l = (int)strlen(buf) + 1;
73 }
74 else if (!diffuse_)
75 {
76 Cerr << "Lec_Diffuse_base::get(...) can't be used with diffuse_=0 on non master process." << finl;
78 }
79 if (diffuse_)
80 {
81 envoyer_broadcast(l, 0);
82 if (l > 0)
83 envoyer_broadcast_array(buf, l, 0);
84 }
85 return error_handle(l < 0);
86}
87
89{
90 int flag = 0;
92 {
94 flag = is.eof();
95 }
96 if (diffuse_) envoyer_broadcast(flag, 0);
97 return flag;
98}
99
101{
102 int flag = 0;
104 {
106 flag = is.good();
107 }
108 if (diffuse_) envoyer_broadcast(flag, 0);
109 return flag;
110}
111
113{
114 int flag = 0;
116 {
118 flag = is.fail();
119 }
120 if (diffuse_) envoyer_broadcast(flag, 0);
121 return flag;
122}
123
124/*! @brief appelle get_entree_master().
125 *
126 * set_bin(bin)
127 *
128 */
130{
132 {
134 is.set_bin(bin);
135 }
136 if (diffuse_) envoyer_broadcast(bin, 0);
137 Entree::set_bin(bin);
138}
139
140/*! @brief appelle get_entree_master().
141 *
142 * set_check_types(flag)
143 *
144 */
146{
149 is.set_check_types(flag);
150}
151
153{
154 diffuse_ = diffuse;
155}
Fichier en lecture Cette classe est a la classe C++ ifstream ce que la classe Entree est a la.
Definition EFichier.h:29
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual int good()
Definition Entree.cpp:270
int error_handle(int fail_flag)
Definition Entree.h:105
virtual int fail()
Definition Entree.cpp:263
virtual int get(int *ob, std::streamsize n)
Definition Entree.cpp:222
bool diffuse_
Definition Entree.h:114
@ ERROR_CONTINUE
Definition Entree.h:93
virtual int eof()
Definition Entree.cpp:256
void set_bin(bool bin) override
Change le mode d'ecriture du fichier.
Definition Entree.cpp:291
Error_Action get_error_action()
renvoie error_action_ pour cette entree (permet de la modifier et de restaurer ensuite la valeur ante...
Definition Entree.cpp:374
virtual void set_check_types(bool flag)
indique si le stream doit verifier les types des objets lus (ints et nombres flottants).
Definition Entree.cpp:313
Classe de base des entrees diffusees: le processeur maitre lit les donnees dans la classe get_entree_...
virtual Entree & get_entree_master()=0
int get(int *ob, std::streamsize n) override
void set_check_types(bool flag) override
appelle get_entree_master().
Entree & operator>>(int &ob) override
Lec_Diffuse_base()
ne fait rien (constructeur protege car c'est une classe de base)
void set_bin(bool bin) override
appelle get_entree_master().
void set_diffuse(bool diffuse) override
ToDo TMA : commenter.
Lec_Diffuse_base & operator=(const Lec_Diffuse_base &)
erreur
friend class Entree
Definition Objet_U.h:76
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
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
Definition Process.cpp:86
Classe de base des flux de sortie.
Definition Sortie.h:52