TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Associer.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 <Associer.h>
17#include <Nom.h>
18
19Implemente_instanciable(Associer,"Associer|Associate",Interprete);
20// XD associate interprete associer INHERITS_BRACE This interpretor allows one object to be associated with another. The
21// XD_CONT order of the two objects in this instruction is not important. The object objet_2 is associated to objet_1 if
22// XD_CONT this makes sense; if not either objet_1 is associated to objet_2 or the program exits with error because it
23// XD_CONT cannot execute the Associate (Associer) instruction. For example, to calculate water flow in a pipe, a
24// XD_CONT Pb_Hydraulique type object needs to be defined. But also a Domaine type object to represent the pipe, a time
25// XD_CONT discretization object (Scheme_euler_explicit for ex.). These two objects must then be associated with the
26// XD_CONT problem.
27// XD attr objet_1 chaine objet_1 REQ Objet_1
28// XD attr objet_2 chaine objet_2 REQ Objet_2
29
30
32{
33 return Interprete::printOn(os);
34}
35
37{
38 return Interprete::readOn(is);
39}
40
41/*! @brief Fonction principale de l'interprete Associer: associer deux objets.
42 *
43 * On essaye d'associer 1 a 2 et 2 a 1, provoque une
44 * erreur si cela echoue.
45 *
46 * @param (Entree& is) un flot d'entree, a partir duquel on lit les noms des objets a associer
47 * @return (Entree&) le flot d'entree modifie
48 * @throws on ne sait pas associer obj1 et obj2
49 */
51{
52 // Acquisition des parametres :
53 Nom nom1, nom2;
54 is >> nom1 >> nom2;
55 if(is.eof())
56 {
57 Cerr << "Reading problem in Associer" << finl;
58 exit();
59 }
60 Objet_U& ob1=objet(nom1);
61 Objet_U& ob2=objet(nom2);
62 int association12,association21;
63 association12=ob1.associer_(ob2);
64 association21=0;
65 if (!association12)
66 {
67 association21=ob2.associer_(ob1);
68 if(!association21)
69 {
70 Cerr << "Impossible to associate objects '" << ob1.que_suis_je()
71 << "' and '" << ob2.que_suis_je() << "'" << finl;
72 exit();
73 }
74 }
75
76 if (association12==2)
77 {
78 Cerr << finl;
79 Cerr << "The medium " << ob2.que_suis_je() << " \"" << nom2
80 << "\" can not be associated to the problem" << finl;
81 Cerr << ob1.que_suis_je() << " \"" << nom1
82 << "\" because it is already associated with another problem." << finl;
83 exit();
84 }
85 if (association21==2)
86 {
87 Cerr << finl;
88 Cerr << "The medium " << ob1.que_suis_je() << " \"" << nom1
89 << "\" can not be associated to the problem" << finl;
90 Cerr << ob2.que_suis_je() << " \"" << nom2
91 << "\" because it is already associated with another problem." << finl;
92 exit();
93 }
94
95 return is;
96}
classe Associer Interprete qui associe deux objets obj1 et obj2:
Definition Associer.h:31
Entree & interpreter(Entree &) override
Fonction principale de l'interprete Associer: associer deux objets.
Definition Associer.cpp:50
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual int eof()
Definition Entree.cpp:256
Classe de base des objets "interprete".
Definition Interprete.h:38
static Objet_U & objet(const Nom &)
Voir Interprete_bloc::objet_global() BM: la classe Interprete n'est pas le meilleur endroit pour cett...
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
friend class Entree
Definition Objet_U.h:76
virtual int associer_(Objet_U &)
Associe l'Objet_U a un autre Objet_U Methode virtuelle a surcharger.
Definition Objet_U.cpp:201
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
Objet_U()
Constructeur par defaut : attribue un numero d'identifiant unique a l'objet (object_id_),...
Definition Objet_U.cpp:55
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