TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Sonde_IJK.cpp
1/****************************************************************************
2* Copyright (c) 2015 - 2016, 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 <Sonde_IJK.h>
17
18#include <IJK_Field.h>
19#include <Probleme_FT_Disc_gen.h>
20#include <Domaine.h>
21#include <Domaine_VF.h>
22#include <Champ_Generique_Interpolation.h>
23#include <communications.h>
24#include <Probleme_FTD_IJK_base.h>
25#include <IJK_tools.h>
26
27Implemente_instanciable( Sonde_IJK, "Sonde_IJK", Sonde ) ;
28
30{
31 return s << que_suis_je();
32}
33
35{
36 ref_ijk_ft_ = ref_cast(Probleme_FTD_IJK_base, mon_post->probleme());
37 ref_ijk_field_ = ref_ijk_ft_->get_IJK_field(nom_champ_lu_);
38 field_name_ = ref_ijk_field_->le_nom();
39
40 // Make sure the cell-projected counterpart of the initial field is registered for postprocessing:
41 if(grav && ref_ijk_field_->get_localisation() != Domaine_IJK::ELEM)
42 ref_ijk_ft_->get_post().register_one_field(ref_ijk_field_->le_nom(), "ELEM");
43
45}
46
48{
49 return Sonde::readOn(is);
50}
51
52/** Override. Exit if invalid type for the probe.
53 */
54void Sonde_IJK::validate_type(const Motcle& loc) const
55{
56 // Valid IJK localisation, all lower case!
57 static constexpr auto VALID = {"point", "points", "segment", "plan", "volume", "segmentxdx",
58 "planxdxdy", "circle", "segmentpoints"
59 };
60
61 std::string s = loc.getString(); // copy
62 // from cppreference - convert to lowercase:
63 std::transform(s.begin(), s.end(), s.begin(),
64 [](unsigned char c) { return std::tolower(c); }
65 );
66
67 if (std::find(VALID.begin(), VALID.end(), s) == VALID.end())
68 Process::exit("ERROR: Invalid localisation for IJK probe!!");
69}
70
71/** Override. Exit if invalid localisation for the probe.
72 */
74{
75 if(chsom || gravcl || nodes || som)
76 Process::exit("ERROR: only 'grav' position modificator is supported for IJK probe!");
77}
78
79const Domaine& Sonde_IJK::get_domaine_geom() const
80{
81 const Domaine_IJK& geom_ft = ref_ijk_ft_->get_domaine_ft();
82 return ref_ijk_ft_->probleme(geom_ft).domaine();
83}
84
86{
87 Noms ret;
88 ret.add(ref_ijk_field_->le_nom());
89 return ret;
90}
91
93{
94 return ref_ijk_field_->nb_comp();
95}
96
97// Here no difference between time of the field, and current time as given by the problem
99{
100 return ref_ijk_ft_->schema_temps().temps_courant();
101}
102
103
104/** In IJK, velocity components might be interpolated/moved to element center.
105 * This is equivalent to having a ELEM field.
106 */
108{
109 fix_probe_position_generic(Domaine_IJK::ELEM);
110}
111
112void Sonde_IJK::fix_probe_position_generic(Domaine_IJK::Localisation loc)
113{
114 int nbre_points = les_positions_sondes_.dimension(0);
115 const Domaine_IJK& geom_ft = ref_ijk_ft_->get_domaine_ft();
116 const Domaine_IJK& field_splitting = ref_ijk_field_->get_domaine();
117 Vecteur3 origin(0., 0., 0.), delta(0., 0., 0.);
118 delta[0] = geom_ft.get_constant_delta(DIRECTION_I);
119 delta[1] = geom_ft.get_constant_delta(DIRECTION_J);
120 delta[2] = geom_ft.get_constant_delta(DIRECTION_K);
121
122 Int3 offset;
123 offset[0] = geom_ft.get_offset_local(DIRECTION_I);
124 offset[1] = geom_ft.get_offset_local(DIRECTION_J);
125 offset[2] = geom_ft.get_offset_local(DIRECTION_K);
126
127 // L'origine est sur un noeud. Donc que la premiere face en I est sur get_origin(DIRECTION_I)
128 origin[0] = geom_ft.get_origin(DIRECTION_I)
129 + ((loc==Domaine_IJK::FACES_J || loc==Domaine_IJK::FACES_K || loc==Domaine_IJK::ELEM) ? (delta[DIRECTION_I] * 0.5) : 0. ) ;
130 origin[1] = geom_ft.get_origin(DIRECTION_J)
131 + ((loc==Domaine_IJK::FACES_K || loc==Domaine_IJK::FACES_I || loc==Domaine_IJK::ELEM) ? (delta[DIRECTION_J] * 0.5) : 0. ) ;
132 origin[2] = geom_ft.get_origin(DIRECTION_K)
133 + ((loc==Domaine_IJK::FACES_I || loc==Domaine_IJK::FACES_J || loc==Domaine_IJK::ELEM) ? (delta[DIRECTION_K] * 0.5) : 0. ) ;
134
135 for (int idx =0; idx < nbre_points; idx++)
136 {
137 const int num_elem = elem_[idx];
138 if (num_elem == -1) continue; // Handle only my processor
139
140 // L'element appartient a ce proc. On peut donc trouver son ijk...
141 // Les autres positions seront mises a jour par les autres procs...
142 const Int3 ijk = geom_ft.convert_packed_to_ijk_cell(num_elem);
143 Int3 new_ijk(ijk);
144
145 // Corrige la position de la sonde :
146 for (int i = 0; i < 3; i++)
147 les_positions_sondes_(idx, i) = origin[i]+(ijk[i]+offset[i])*delta[i];
148 Cerr << "Sonde " << nom_ << " Point " << idx
149 << " x= " << les_positions_sondes_(idx, 0)
150 << " y= " << les_positions_sondes_(idx, 1)
151 << " z= " << les_positions_sondes_(idx, 2) << finl;
152
153 //
154 // TODO ABN to be removed once no more extended domain:
155 // TODO: GB : So strange, geom_ft.ft_extension() = 0 whereas field_splitting.ft_extension() !=0
156 if ((field_splitting != geom_ft) &&
157 (field_splitting.ft_extension() != 0))
158 //(geom_ft.ft_extension() != 0))
159 {
160 // Les 2 splittings ne sont pas identiques il faut changer l'elem :
161 for (int i = 0; i < 3; i++)
162 {
163 //Cerr << " " << (field_geom.get_origin(i)-geom.get_origin(i))/delta[i] << finl;
164 if (geom_ft.get_periodic_flag(i))
165 {
166 //assert(int((field_geom.get_origin(i)-geom.get_origin(i))/delta[i]) == ref_ijk_ft_->get_splitting_extension());
167 new_ijk[i] -= field_splitting.ft_extension();
168 }
169 }
170 const int new_num_elem = field_splitting.convert_ijk_cell_to_packed(new_ijk[0], new_ijk[1], new_ijk[2]);
171 elem_[idx] = new_num_elem;
172 }
173 }
174}
175
176/** Fix probe position. In IJK, if no position modifier is specified, we systematically
177 * move the probe to the center of the element for a ELEM field, and to the face corresponding to the field
178 * component if this is a FACE field.
179 */
181{
182 const Domaine_IJK::Localisation loc = ref_ijk_field_->get_localisation();
183 fix_probe_position_generic(loc);
184}
185
187{
188 valeurs_locales.resize(elem_.size(),1); // WARNING: must be dim 2 to be compatible with TRUST ...
189 const int nb_pts = elem_.size();
190
191 // Make sure to call get_IJK_field() to trigger the update of the field:
192 const IJK_Field_double* ijk_field = &(ref_ijk_ft_->get_IJK_field(field_name_));
193 const Domaine_IJK& dom = ijk_field->get_domaine();
194
195 // If necessary, interpolate to cell center:
196 if(grav && ref_ijk_field_->get_localisation() != Domaine_IJK::ELEM)
197 {
198 if( tmp_storage_.ni() == 0 )
199 tmp_storage_ = *ijk_field; // deep copy
200 interpolate_to_center_compo(tmp_storage_, *ijk_field);
201 ijk_field = &tmp_storage_;
202 }
203
204 for (int idx =0; idx < nb_pts; idx++)
205 {
206 const int num_elem = elem_[idx];
207 if (num_elem < 0)
208 {
209 Cerr << "ERROR - Sonde_IJK::fill_local_values() - the probe '" << nom_ << "' defines point #" << idx << " which falls outside the domain!!" << finl;
211 }
212 const Int3 ijk = dom.convert_packed_to_ijk_cell(num_elem);
213 valeurs_locales[idx] = (*ijk_field)(ijk[0],ijk[1],ijk[2]);
214 }
215}
216
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
Definition Domaine_IJK.h:47
int get_offset_local(int direction) const
Returns the local offset in requested direction.
bool get_periodic_flag(int direction) const
Method returns true if periodic in this direction.
int ft_extension() const
double get_constant_delta(int direction) const
Returns the size of cells in a direction.
double get_origin(int direction) const
Returns the coordinate of the first node (global) of the mesh in the requested direction.
int convert_ijk_cell_to_packed(const FixedVector< int, 3 > ijk) const
Converts the ijk index of an element to a cell index.
FixedVector< int, 3 > convert_packed_to_ijk_cell(int index) const
Convert the local index of an element to a vector with IJK indices.
Localisation
Localisation sub class.
Definition Domaine_IJK.h:53
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Domaine_IJK & get_domaine() const
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
const std::string & getString() const
Definition Nom.h:92
Un tableau de chaine de caracteres (VECT(Nom)).
Definition Noms.h:26
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
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
const Probleme_base & probleme(const Domaine_IJK &dom) const
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
class Sonde_IJK
Definition Sonde_IJK.h:29
double get_temps_champ() const override
Definition Sonde_IJK.cpp:98
const Domaine & get_domaine_geom() const override
Definition Sonde_IJK.cpp:79
IJK_Field_double tmp_storage_
Definition Sonde_IJK.h:52
void fix_probe_position_grav() override
void fix_probe_position() override
void validate_type(const Motcle &loc) const override
Definition Sonde_IJK.cpp:54
const Noms get_noms_champ() const override
Definition Sonde_IJK.cpp:85
int get_nb_compo_champ() const override
Definition Sonde_IJK.cpp:92
void validate_position() const override
Definition Sonde_IJK.cpp:73
void completer() override
Definition Sonde_IJK.cpp:34
void fill_local_values() override
classe Sonde Cette classe permet d'effectuer l'evolution d'un champ au cours du temps.
Definition Sonde.h:41
DoubleTab valeurs_locales
Definition Sonde.h:120
Motcle nom_champ_lu_
Definition Sonde.h:123
bool som
Definition Sonde.h:119
bool chsom
Definition Sonde.h:116
IntVect elem_
les elements contenant les sondes ponctuelles locales
Definition Sonde.h:111
bool grav
Definition Sonde.h:117
virtual void initialiser()
Initialise la sonde.
Definition Sonde.cpp:798
Nom nom_
le nom de la sonde
Definition Sonde.h:99
bool gravcl
Definition Sonde.h:118
DoubleTab les_positions_sondes_
les coordonnees des sondes sur tout le domaine apres deplacement (uniquement sur le maitre)
Definition Sonde.h:108
bool nodes
Definition Sonde.h:115
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133