TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Input_Proto.cpp
1/****************************************************************************
2* Copyright (c) 2023, 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 <Convert_ICoCoTrioField.h>
17#include <Champ_Input_Proto.h>
18#include <Schema_Temps_base.h>
19#include <ICoCoExceptions.h>
20#include <Probleme_base.h>
21#include <Interprete.h>
22#include <TRUSTTab.h>
23#include <Domaine.h>
24
25using ICoCo::WrongArgument;
26
27/*! @brief Lecture d'un champ input dans un flot d'entree Factorisation des readOn des differents Champ_input
28 *
29 * Format:
30 * { nb_comp nombre_de_composantes_du_champ
31 * nom nom_du_champ
32 * probleme nom_du_probleme_base_associe
33 * [sous_domaine nom_du_sous_domaine_associe] }
34 *
35 * @param (Entree& is) flot d'entree
36 * @return le flot d'entre modifie
37 * @throws pas d'accolade ouvrante en debut de format
38 * Exception : un des 3 motcles absent, autre motcle non compris
39 * @throws pas d'accolade fermante en fin de jeu de donnee
40 */
42{
43 Nom nom_champ;
44 Nom nom_pb;
45 Nom nom_sous_domaine;
46 int nbc=-1;
47
48 // Lire nom_champ et nom_pb
49 Motcle accolade_ouverte("{");
50 Motcle accolade_fermee("}");
51 Motcle motlu;
52 is >> motlu;
53 if (motlu != accolade_ouverte)
54 {
55 Cerr << "It was expected { to start to read the Champ_Input" << finl;
57 }
58 is >> motlu;
59 while(1)
60 {
61 if (motlu == "nb_comp")
62 {
63 is >> nbc;
64 set_nb_comp(nbc);
65 }
66 else if (motlu == "nom")
67 {
68 is >> nom_champ;
69 }
70 else if (motlu == "initial_value")
71 {
72 is >> initial_value_;
73 }
74 else if (motlu=="probleme")
75 {
76 is >> nom_pb;
77 }
78 else if (motlu=="sous_domaine" || motlu=="sous_zone")
79 {
80 is >> nom_sous_domaine;
81 }
82 else if (motlu == accolade_fermee)
83 break;
84 else
85 {
86 Cerr << "Error in Ch_front_input_uniforme::readOn" << finl;
87 Cerr << "We expected a } instead of " << motlu << finl;
89 }
90 is >> motlu;
91 }
92 if (nom_champ=="??" || nom_pb=="??" || nbc==-1)
93 {
94 Cerr << "Error in Ch_front_input_uniforme::readOn" << finl;
95 Cerr << "It must be define the name, problem and number of components" << motlu << finl;
97 }
98 // Nommer le champ
99 set_name(nom_champ);
100
101 // Retrouver le probleme et s'inscrire dans sa liste
102 mon_pb=ref_cast(Probleme_base,Interprete::objet(nom_pb));
103
104 mon_sous_domaine.reset();
105 if (nom_sous_domaine!="??")
106 {
107 if (!sous_domaine_ok)
108 {
109 Cerr << "Error in Ch_front_input_uniforme::readOn" << finl;
110 Cerr << "The sous_domaines are not managed by this field" << finl;
112 }
113 mon_sous_domaine=mon_pb->domaine().ss_domaine(nom_sous_domaine);
114 }
115}
116
117void Champ_Input_Proto::setValueOnTab(const TrioField& afield, DoubleTab& tab)
118{
119 if (afield._type==0)
120 {
121 if ((afield._nb_elems!=tab.dimension(0))&&(afield._nb_elems!=tab.dimension_tot(0)))
122 {
123
124 throw WrongArgument(mon_pb->le_nom().getChar(),"setInputField",afield.getCharName(),"should have the same _nb_elems as returned by getInputFieldTemplate");
125 }
126 }
127 else
128 {
129 if (afield._nbnodes!=tab.dimension(0))
130 throw WrongArgument(mon_pb->le_nom().getChar(),"setInputField","afield","should have the same _nb_elems as returned by getInputFieldTemplate");
131 if (afield._nb_field_components!=tab.dimension(1))
132
133 throw WrongArgument(mon_pb->le_nom().getChar(),"setInputField","afield","should have the same _nb_field_components as returned by getInputFieldTemplate");
134 }
135 // order is c1 c2 c3 c1 c2 c3 c1 c2 c3
136 memcpy(tab.addr(),afield._field,tab.size()*sizeof(double));
138}
139
140void Champ_Input_Proto::setInitialValue(const ArrOfDouble& vo)
141{
143}
144
146{
147 Cerr<< "You need to override setDoubleValue() in derived class of Champ_Input_Proto"<< finl;
148 throw;
149}
virtual void set_name(const Nom &name)=0
virtual void set_nb_comp(int i)=0
void setValueOnTab(const TrioField &afield, DoubleTab &tab)
void read(Entree &is)
Lecture d'un champ input dans un flot d'entree Factorisation des readOn des differents Champ_input.
void setInitialValue(const ArrOfDouble &vo)
virtual void setDoubleValue(const double val)
ArrOfDouble initial_value_
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...
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
_TYPE_ * addr()
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
_SIZE_ size() const
Definition TRUSTVect.tpp:45
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")