TrioCFD 1.9.9_beta
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 Does nothing (protected constructor since this is a base class).
34 *
35 */
37
38/*! @brief Error.
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 Calls 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 Calls 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}
File for reading. This class is to the C++ ifstream class what the Entree class is to the.
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
Changes the file write mode.
Definition Entree.cpp:291
Error_Action get_error_action()
Returns error_action_ for this input (allows modifying it and restoring the previous value afterwards...
Definition Entree.cpp:371
virtual void set_check_types(bool flag)
Indicates whether the stream should verify the types of read objects (ints and floating-point numbers...
Definition Entree.cpp:313
Base class for diffused inputs: the master processor reads data from get_entree_master() and broadcas...
virtual Entree & get_entree_master()=0
int get(int *ob, std::streamsize n) override
void set_check_types(bool flag) override
Calls get_entree_master().
Entree & operator>>(int &ob) override
Lec_Diffuse_base()
Does nothing (protected constructor since this is a base class).
void set_bin(bool bin) override
Calls get_entree_master().
void set_diffuse(bool diffuse) override
Sets the diffuse flag for this input stream.
Lec_Diffuse_base & operator=(const Lec_Diffuse_base &)
Error.
friend class Entree
Definition Objet_U.h:71
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
Definition Process.cpp:82
Base class for output streams.
Definition Sortie.h:52