17#include <Champs_compris_IJK.h>
25 auto item = liste_champs_vecto_.find(nom.
getString());
26 return item != liste_champs_vecto_.end();
32 auto item = liste_champs_vecto_.find(nom.
getString());
33 if (item != liste_champs_vecto_.end())
return item->second;
34 throw std::runtime_error(std::string(
"Vectoriel field ") + nom.
getString() + std::string(
" not found !"));
40 auto add_key = [&](
const Nom& n)
44 Cerr <<
"Champs_compris_IJK::ajoute_champ_vectoriel : trying to add a field with no name" << finl;
47 std::string nom_champ = n.getString();
48 std::string upperCase = nom_champ, lowerCase = nom_champ;
49 std::transform(nom_champ.begin(), nom_champ.end(), upperCase.begin(), ::toupper);
50 std::transform(nom_champ.begin(), nom_champ.end(), lowerCase.begin(), ::tolower);
55 Cerr <<
"Champs_compris_IJK::ajoute_champ_vectoriel : trying to add a field twice : " << upperCase << finl;
58 liste_champs_vecto_[upperCase] = champ;
59 liste_champs_vecto_[lowerCase] = champ;
63 add_key(champ.le_nom());
66 const Noms& syno = champ.get_synonyms();
67 int nb_syno = syno.size();
68 for (
int s = 0; s < nb_syno; s++)
72 int nb_composantes = champ.nb_comp();
73 for (
int i = 0; i < nb_composantes; i++)
76 Cerr<<
"Champs_compris_IJK::ajoute_champ_vectoriel " << champ.le_nom() <<finl;
82 for (
auto const& champ : liste_champs_vecto_)
83 nom_compris.add(champ.first);
89 Cerr <<
"Champs_compris_IJK : start switch old to next" <<finl;
93 Nom old_name = old.first;
94 switch_field(old_name,
"OLD_");
95 switch_field(old_name,
"old_");
98 for (
auto& old : liste_champs_vecto_)
100 Nom old_name = old.first;
101 switch_vector_field(old_name,
"OLD_");
102 switch_vector_field(old_name,
"old_");
105 Cerr <<
"Champs_compris_IJK : end switch old to next" <<finl;
111void Champs_compris_IJK::switch_field(
const Nom& field_name,
const Nom& prefix)
122 Cerr <<
"Champs_compris_IJK : field " << next_name <<
" not found for swapping with " << field_name <<finl;
123 Cerr <<
"Champs_compris_IJK : Warning: only name fields with prefix OLD_ if they are in IJK_Interface and using the next/old semantic" <<finl;
136 Cerr <<
"Champs_compris_IJK : swapping IJK field " << field_name <<
" with " << next_name <<finl;
141void Champs_compris_IJK::switch_vector_field(
const Nom& field_name,
const Nom& prefix)
146 Nom next_name = field_name.
getSuffix(prefix);
150 if (next == liste_champs_vecto_.end())
152 Cerr <<
"Champs_compris_IJK : field " << next_name <<
" not found for swapping with " << field_name <<finl;
153 Cerr <<
"Champs_compris_IJK : Warning: only name fields with prefix OLD_ if they are in IJK_Interface and using the next/old semantic" <<finl;
158 auto ptr = liste_champs_vecto_[field_name.
getString()];
159 liste_champs_vecto_[field_name.
getString()]=liste_champs_vecto_[next_name.
getString()];
160 liste_champs_vecto_[next_name.
getString()]=ptr;
163 liste_champs_vecto_[field_name.
getString()]->nommer(field_name);
164 liste_champs_vecto_[next_name.
getString()]->nommer(next_name);
166 Cerr <<
"Champs_compris_IJK : swapping IJK field vector " << field_name <<
" with " << next_name <<finl;
175 nom_compris.add(champ.first);
bool has_champ_vectoriel(const Motcle &nom) const
const Noms liste_noms_compris() const
const IJK_Field_vector3_double & get_champ_vectoriel(const Motcle &nom) const
void ajoute_champ_vectoriel(const IJK_Field_vector3_double &champ)
const Noms liste_noms_compris_vectoriel() const
std::unordered_map< std::string, OBS_PTR(IJK_Field_double)> liste_champs_
void ajoute_champ(const IJK_Field_double &champ)
Une chaine de caractere (Nom) en majuscules.
class Nom Une chaine de caractere pour nommer les objets de TRUST
const Nom getSuffix(const char *const) const
virtual int debute_par(const char *const n) const
virtual int find(const char *const n) const
const std::string & getString() const
Un tableau de chaine de caracteres (VECT(Nom)).
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.