TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Sous_Domaines.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//
17// File: Sous_Domaines.cpp
18// Directory: $TRUST_ROOT/src/Kernel/Utilitaires
19// Version: /main/7
20//
21//////////////////////////////////////////////////////////////////////////////
22
23#include <Sous_Domaines.h>
24#include <Param.h>
25#include <Domaine.h>
26#include <EChaine.h>
27#include <Synonyme_info.h>
28#include <Interprete.h>
29
30Implemente_instanciable(Sous_Domaines,"Sous_Domaines",VECT(Sous_Domaine));
31Add_synonym(Sous_Domaines, "Sous_Zones");
32
33Sortie& Sous_Domaines::printOn(Sortie& s) const
34{
35 return VECT(Sous_Domaine)::printOn(s);
36}
37
38// Syntaxe identique au decoupeur tranches mais en specifiant un domaine pour la bounding box: { bounding_box domaine_name tranches Nx Ny [Nz] }
39Entree& Sous_Domaines::readOn(Entree& s)
40{
41 Motcle ouvert,ferme,bounding_box,tranches;
42 ArrOfInt n(dimension);
43 n=1;
44 Nom nom_domaine;
45 s >> ouvert >> bounding_box >> nom_domaine >> tranches;
46 for (int dir=0; dir<dimension; dir++) s >> n[dir];
47 s >> ferme;
48 if (ouvert!="{" || bounding_box!="BOUNDING_BOX" || tranches!="TRANCHES" || ferme!="}")
49 Process::exit("Syntax is: Lire|Read Sous_Domaines { bounding_box domaine_name tranches Nx Ny [Nz] }");
50 DoubleTab BB = ref_cast(Domaine, Interprete::objet(nom_domaine)).getBoundingBox();
51 ArrOfDouble cotes(dimension);
52 double alpha = 1.0001; // Astuce pour pouvoir decouper par faisceau ou demi-faisceau si le canal de croix est maille (mais alors decoupage non equilibre)
53 for (int dir=0; dir<dimension; dir++)
54 {
55 BB(dir, 0) = mp_min(BB(dir, 0));
56 BB(dir, 1) = mp_max(BB(dir, 1));
57 cotes(dir) = (BB(dir, 1) - BB(dir,0)) / n[dir] * alpha;
58 }
59 Domaine& dom = ref_cast(Sous_Domaine, front()).domaine();
60 dimensionner_force(0);
61 int canal=0;
62 int nb_elem_ssz = 0;
63 for (int i=0; i<n[0]; i++)
64 for (int j=0; j<n[1]; j++)
65 for (int k=0; k<n[2]; k++)
66 {
67 // Creation d'une Sous_Domaine de type Rectangle/Boite
68 Nom tmp("{ ");
69 tmp+=(dimension==2 ? "Rectangle " : "Boite ");
70 tmp+=" Origine";
71 for (int dir=0; dir<dimension; dir++)
72 {
73 tmp += " ";
74 tmp += (Nom)(BB(dir, 0) + (dir==0 ? i : (dir==1 ? j : k))*cotes(dir));
75 }
76 tmp+=" Cotes";
77 for (int dir=0; dir<dimension; dir++)
78 {
79 tmp += " ";
80 tmp += (Nom)cotes(dir);
81 }
82 tmp+=" }";
83 //Cerr << "Echaine: " << tmp << finl;
84 Sous_Domaine& ssz = add(Sous_Domaine());
85 ssz.associer_domaine(dom);
86 Nom name(dom.le_nom());
87 name+="_Sous_Domaine_";
88 name+=(Nom)canal;
89 ssz.nommer(name);
90 EChaine is(tmp);
91 is >> ssz;
92 if (ssz.nb_elem_tot()!=0)
93 {
94 dom.add(ssz);
95 nb_elem_ssz+=ssz.nb_elem_tot();
96 canal++;
97 }
98 }
99 // Add check:
100 if (nb_elem_ssz!=dom.nb_elem_tot())
101 {
102 Cerr << "Error, all the domain is not covered by subdomaines:" << finl;
103 Cerr << "There is " << dom.nb_elem_tot() - nb_elem_ssz << " cells not marked." << finl;
105 }
106 return s;
107}
108
110{
111 if (sub_type(Domaine, ob))
112 {
113 // Creation d'une premiere sous_domaine pour stocker reference vers domaine/domaine
114 Sous_Domaine& ssz = add(Sous_Domaine());
115 ssz.associer_domaine(ref_cast(Domaine, ob));
116 return 1;
117 }
118 else
119 Process::exit("You need to associate a Domaine to Sous_Domaines.");
120 return 0;
121}
int_t nb_elem_tot() const
Definition Domaine.h:132
void add(const Sous_Domaine_t &sd)
Definition Domaine.h:294
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
static Objet_U & objet(const Nom &)
Voir Interprete_bloc::objet_global() BM: la classe Interprete n'est pas le meilleur endroit pour cett...
classe Objet_U Cette classe est la classe de base des Objets de TRUST
Definition Objet_U.h:73
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
void nommer(const Nom &nom) override
Donne un nom a l'Objet_U Methode virtuelle a surcharger.
void associer_domaine(const Domaine_t &d)
Un vecteur de Sous_Domaine (VECT(Sous_Domaine)).
int associer_(Objet_U &ob) override