TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Interpolation_IBM_elem_fluid.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 <Interpolation_IBM_elem_fluid.h>
17#include <Source_PDF_base.h>
18#include <TRUSTTrav.h>
19#include <Domaine.h>
20#include <Param.h>
21
22Implemente_instanciable( Interpolation_IBM_elem_fluid, "Interpolation_IBM_element_fluide|IBM_element_fluide", Interpolation_IBM_base ) ;
23// XD interpolation_ibm_elem_fluid interpolation_ibm_base ibm_element_fluide BRACE Immersed Boundary Method (IBM): fluid
24// XD_CONT element interpolation.
25
27{
29}
30
32{
34 param.ajouter("points_fluides",&fluid_points_lu_,Param::OPTIONAL); // XD_ADD_P field_base
35 // XD_CONT Node field giving the projection of the point below (points_solides) falling into the pure cell fluid
36 param.ajouter("points_solides",&solid_points_lu_,Param::OPTIONAL); // XD_ADD_P field_base
37 // XD_CONT Node field giving the projection of the node on the immersed boundary
38 param.ajouter("elements_fluides",&fluid_elems_lu_,Param::OPTIONAL); // XD_ADD_P field_base
39 // XD_CONT Node field giving the number of the element (cell) containing the pure fluid point
40 param.ajouter("correspondance_elements",&corresp_elems_lu_,Param::OPTIONAL); // XD_ADD_P field_base
41 // XD_CONT Cell field giving the SALOME cell number
42 param.ajouter_flag("get_fluid_points_from_prepro", &fluid_points_from_prepro_); // XD_ADD_P rien
43 // XD_CONT get IBM fluid points from prepro.
44 param.ajouter_flag("get_fluid_elems_from_prepro", &fluid_elems_from_prepro_); // XD_ADD_P rien
45 // XD_CONT get IBM fluid elems from prepro.
46}
47
49{
50 Param param(que_suis_je());
51 set_param(param);
52 param.lire_avec_accolades_depuis(is);
53 return is;
54}
55
57{
59 int nb_comp = Objet_U::dimension;
60 Noms units(nb_comp);
61 Noms c_nam(nb_comp);
62
63 dis.discretiser_champ("champ_sommets",le_dom_dis,"fluid_elems","none",1,0., fluid_elems_);
65 {
66 OBS_PTR(Prepro_IBM_base) my_prep = my_source_->getpreproLu();
67 if (my_prep)
68 {
69 DoubleTab& the_values = ref_cast_non_const(DoubleTab, my_prep->get_champ_fluid_elems());
70 fluid_elems_->valeurs() = the_values;
71 }
72 }
73 else
74 {
75 if (fluid_elems_lu_) fluid_elems_->affecter(fluid_elems_lu_);
76 }
77
78 if (corresp_elems_) has_corresp_ = true;
79
80 dis.discretiser_champ("champ_sommets",le_dom_dis,vectoriel,c_nam,units,nb_comp,0.,fluid_points_);
82 {
83 OBS_PTR(Prepro_IBM_base) my_prep = my_source_->getpreproLu();
84 if (my_prep)
85 {
86 DoubleTab& the_values = ref_cast_non_const(DoubleTab, my_prep->get_champ_fluid_points());
87 fluid_points_->valeurs() = the_values;
88 }
89 }
90 else
91 {
92 if (fluid_points_lu_) fluid_points_->affecter(fluid_points_lu_);
93 }
94 computeFluidElems(le_dom_dis);
95}
96
98{
99 double eps = 1e-12;
100 int nb_som = le_dom_dis.nb_som();
101 int nb_som_tot = le_dom_dis.nb_som_tot();
102 int nb_elem = le_dom_dis.nb_elem();
103 int nb_elem_tot = le_dom_dis.nb_elem_tot();
104 const DoubleTab& coordsDom = le_dom_dis.domaine().coord_sommets();
105 // const IntTab& elems = le_dom_dis.domaine().les_elems();
106
107 DoubleTab& elems_fluid_ref = fluid_elems_->valeurs();
108 DoubleTab& fluid_points_ref = fluid_points_->valeurs();
109 DoubleTab& solid_points_ref = solid_points_->valeurs();
110
111 // La numerotation des elements peut avoir changee entre l'etape pre_pro et
112 // l'etape calcul (cas du pre_pro Salome)
113 // On utilise un champ d'etiquette pour fluid_elems_ (par exemple le no elem Salome)
114 // et un champ d'element reprenant ces etiquettes
115 if (corresp_elems_)
116 {
117 DoubleTab& corresp_elems_ref = corresp_elems_->valeurs();
118 int nb_tag_max = -1;
119 for (int i = 0 ; i < nb_elem_tot ; i++)
120 {
121 int int_cor_elem = (int)lrint(corresp_elems_ref(i));
122 if (int_cor_elem > nb_tag_max) nb_tag_max = int_cor_elem;
123 }
124 int dimtag = nb_tag_max+1;
125 DoubleTrav elems_fluid_trust(dimtag);
126 elems_fluid_trust = -1.e+10;
127 for (int i = 0 ; i < nb_elem_tot ; i++)
128 {
129 int indextag = (int)lrint(corresp_elems_ref(i)) ;
130 //Cerr << indextag << ", " << dimtag << ", " << nb_elem << ", " << nb_elem_tot << ", " << nb_som << ", " << nb_som_tot << finl;
131 //abort();
132 if (indextag < dimtag && indextag >= 0)
133 {
134 elems_fluid_trust(indextag) = i*1.0;
135 }
136 else
137 {
138 Cerr<<"erreur in computeFluidElems : elem corresp_elems_ref(elem) = "<<i<<" "<<corresp_elems_ref(i)<<" ; indextag = "<<indextag<<" < 0 ou >= "<<dimtag<<finl;
139 exit();
140 }
141 }
142 for (int i = 0 ; i < nb_som ; i++)
143 {
144 if (elems_fluid_ref(i) >= 0.0)
145 {
146 int indexr = (int)lrint(elems_fluid_ref(i));
147 if (indexr < dimtag && indexr >= 0)
148 {
149 if (elems_fluid_trust(indexr) >= 0.)
150 {
151 elems_fluid_ref(i) = elems_fluid_trust(indexr);
152 }
153 else
154 {
155 double x = fluid_points_ref(i,0);
156 double y = fluid_points_ref(i,1);
157 double z = fluid_points_ref(i,2);
158 double xs = solid_points_ref(i,0);
159 double ys = solid_points_ref(i,1);
160 double zs = solid_points_ref(i,2);
161 double d = (x-xs)*(x-xs)+(y-ys)*(y-ys)+(z-zs)*(z-zs);
162 if (d < eps)
163 // A ne pas considerer si points fluide et solide sont confondus (erreur prepro)
164 {
165 elems_fluid_ref(i) = elems_fluid_trust(indexr);
166 }
167 else
168 {
169 Cerr << __FILE__ << (int)__LINE__ << "Interpolation_IBM_elem_fluid::computeFluidElems : ERROR : joint width too low?" << finl;
170 Cerr<<"node elems_fluid_ref(node) index = "<<i<<" "<<elems_fluid_ref(i)<<" "<<indexr<<finl;
171 Cerr<<"elems_fluid_trust(index) < 0. = "<<elems_fluid_trust(indexr)<<finl;
172 Cerr<<"nb som som_tot elem elem_tot = "<<nb_som<<" "<<nb_som_tot<<" "<<nb_elem<<" "<<nb_elem_tot<<finl;
173 Cerr<<"coords_point(node) : x y z = "<<coordsDom(i,0)<<" "<<coordsDom(i,1)<<" "<<coordsDom(i,2)<<finl;
174 Cerr<<"fluid_points(node) : xf yf zf = "<<x<<" "<<y<<" "<<z<<finl;
175 Cerr<<"solid_points(node) : xs ys zs = "<<xs<<" "<<ys<<" "<<zs<<finl;
176 int elem_found = le_dom_dis.domaine().chercher_elements(x,y,z);
177 Cerr<<"chercher_elements(xf,yf,zf) = "<<elem_found<<finl;
178 if (elem_found != -1)
179 elems_fluid_ref(i) = elem_found;
180 else
181 exit();
182 }
183 }
184 }
185 else
186 {
187 Cerr << __FILE__ << (int)__LINE__ << "Interpolation_IBM_elem_fluid::computeFluidElems : ERROR : joint width too low?" << finl;
188 Cerr<<"node elems_fluid_ref(node) = "<<i<<" "<<elems_fluid_ref(i)<<finl;
189 Cerr<<"index = "<<indexr<<" < 0 ou >= "<<dimtag<<finl;
190 exit();
191 }
192 }
193 }
194 }
195}
196
198{
200 fluid_points_->valeurs() = un_prepro.get_champ_fluid_points();
201 fluid_elems_->valeurs() = un_prepro.get_champ_fluid_elems();
202}
classe Discretisation_base Cette classe represente un schema de discretisation en espace,...
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, const Nom &nom, const Nom &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base)&champ, const Nom &sous_type=NOM_VIDE) const
SmallArrOfTID_t & chercher_elements(const DoubleTab &pos, SmallArrOfTID_t &elem, int reel=0) const
Recherche des elements contenant les points dont les coordonnees sont specifiees.
Definition Domaine.cpp:405
const DoubleTab_t & coord_sommets() const
Definition Domaine.h:112
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
int nb_elem_tot() const
const Domaine & domaine() const
int nb_som_tot() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
void set_param(Param &) const override
virtual void set_fields_from_prepro_to_interp(Prepro_IBM_base &)
virtual void discretise(const Discretisation_base &, Domaine_dis_base &)
OBS_PTR(Source_PDF_base) my_source_
void set_fields_from_prepro_to_interp(Prepro_IBM_base &) override
void discretise(const Discretisation_base &, Domaine_dis_base &) override
virtual void computeFluidElems(Domaine_dis_base &)
Un tableau de chaine de caracteres (VECT(Nom)).
Definition Noms.h:26
static int dimension
Definition Objet_U.h:99
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
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter_flag(const char *keyword, const bool *value)
Register a boolean flag whose mere presence switches it to true.
Definition Param.cpp:474
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
@ OPTIONAL
Definition Param.h:115
const DoubleTab & get_champ_fluid_elems()
const DoubleTab & get_champ_fluid_points()
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