16#include <Perte_Charge_Singuliere.h>
19#include <Domaine_VF.h>
20#include <Sous_Domaine.h>
22#include <Source_base.h>
24#include <Equation_base.h>
25#include <Milieu_base.h>
26#include <Discretisation_base.h>
28#include <Pb_Multiphase.h>
31extern void convert_to(
const char *s,
double& ob);
56 Nom obsolete(
""), alpha_str(
""), deb_str;
60 param.
ajouter(
"eps", &obsolete);
61 param.
ajouter(
"alpha", &alpha_str);
65 Cerr <<
"Syntax error!" << finl;
66 Cerr <<
"The flow rate regulation formula has changed from:" << finl;
67 Cerr <<
"K_ *= min(max(|debit|/deb_cible)^2,(1-eps)^dt),(1+eps)^dt);" << finl;
68 Cerr <<
"to:" << finl;
69 Cerr <<
"K_ += dt*alpha*(debit-debit_cible);" << finl;
70 Cerr <<
"The keyword eps (value between 0 and 1) is no longer valid." << finl;
71 Cerr <<
"The amplitude of the flow rate regulation must be specified by the keyword alpha. If you had a non-zero value for eps, e.g. 0.5, replace with alpha 10" << finl;
72 Cerr <<
"and eps 0 must be replaced by alpha 0" << finl;
75 if (alpha_str==
"")
Process::exit(
"alpha must be specified for the regulation.");
88 les_motcles[0] =
"KX";
89 les_motcles[1] =
"KY";
90 les_motcles[2] =
"KZ";
94 if (motlu != acc_ouverte)
96 Cerr <<
"We expected the keyword" << acc_ouverte <<
" instead of " << motlu << finl;
102 Cerr <<
"We expected the keyword dir instead of " << motlu << finl;
108 int rang = les_motcles.
search(motlu);
111 Cerr <<
"Error while reading the data of Perte_Charge_Singuliere" << finl;
112 Cerr <<
"We expected one of the keywords " << les_motcles << finl;
113 Cerr <<
"instead of " << motlu << finl;
120 if (motlu ==
"regul")
122 else if (motlu ==
"coeff")
125 convert_to(motlu.getChar(),
K_);
129 Cerr <<
"We expected the keyword coeff or regul instead of " << motlu << finl;
134 Cerr <<
" pressure drop K_ " <<
K_ << finl;
140 const Domaine_dis_base& domaine_dis, IntVect& les_faces, IntVect& sgn,
int lire_derniere_accolade)
144 const DoubleTab& xv = zvf.
xv();
157 Nom nom_ss_domaine, nom_surface;
162 if (motlu !=
"surface")
164 Cerr <<
"We expected the keyword surface instead of " << motlu << finl;
168 if (motlu != acc_ouverte)
170 Cerr <<
"We expected the keyword" << acc_ouverte <<
" instead of " << motlu << finl;
174 if (method==
"X" || method==
"Y" || method==
"Z")
178 Nom direction=method, egal;
199 Cerr <<
"The section specified " << direction <<
" is not coherent with the coefficient pressure loss direction indicated by " << dir << finl;
200 Cerr <<
"Here the section to specify is " << sect <<
"." << finl;
204 is >> egal >> position;
205 is >> nom_ss_domaine;
206 Cerr <<
" position " << direction <<
" " << position << finl;
209 else if (method==
"Surface")
224 Cerr <<
"Error in Perte_Charge_Singuliere::lire_surfaces" << finl;
225 Cerr <<
"The keyword " << method <<
" specified for plan definition is only possible in VEF discretization !" << finl;
226 Cerr <<
"You must used the method of intersection between subdomaine and location of plane." << finl;
230 Cerr <<
" surface " << nom_surface << finl;
233 else if (method==
"Face_group")
238 Cerr <<
" surface " << nom_surface << finl;
243 Cerr <<
"Error in Perte_Charge_Singuliere::lire_surfaces" << finl;
244 Cerr <<
"The keyword " << method <<
" specified for plan definition is not coherent !" << finl;
248 if (motlu ==
"orientation") is >> orientation, is >> motlu;
250 if (motlu != acc_fermee)
252 Cerr <<
"We expected the keyword" << acc_fermee <<
" instead of " << motlu << finl;
255 if (lire_derniere_accolade)
258 if (motlu != acc_fermee)
260 Cerr <<
"We expected the keyword" << acc_fermee <<
" instead of " << motlu << finl;
270 const Sous_Domaine& ssz = le_domaine.
ss_domaine(nom_ss_domaine);
271 int coord = method ==
"X" ? 0 : method ==
"Y" ? 1 : 2;
274 for (
int j=0; j<nfe; j++)
276 int numfa = elem_faces(ssz(poly),j);
278 if (numfa >= 0 && est_egal(xv(numfa,coord),position) )
281 for (
int i=0; i<compteur; i++)
282 if (les_faces[i]==numfa)
287 if (trouve==0) les_faces[compteur++] = numfa, face_tab(numfa) = 1;
296 const Domaine& le_domaine2D = ref_cast(Domaine,le_domaine.
interprete().
objet(nom_surface));
297 const DoubleTab& coord_sommets_2D=le_domaine2D.
coord_sommets();
309 Cerr <<
" Surface " << nom_surface <<
" with " << nb_elem_2D <<
" faces" << finl;
310 for (
int ind_face=0; ind_face<nb_elem_2D; ind_face++)
313 ArrOfInt elem_list_vol;
316 zv2d=xv2D(ind_face,2);
317 octree_vol.
rang_elems_sommet(elem_list_vol,xv2D(ind_face,0),xv2D(ind_face,1),zv2d);
320 for (
int ind_elem=0; ind_elem<nb_elem_vol; ind_elem++)
322 int elem = elem_list_vol[ind_elem];
324 for (
int j=0, numfa; j < nfe && (numfa = elem_faces(elem,j)) >= 0; j++)
331 for (
int k = 0, numso; k < nse2D && (numso = face_sommets(numfa, k)) >= 0; k++)
334 double xcoord_vol=coord_sommets(numso,0);
335 double ycoord_vol=coord_sommets(numso,1);
339 zcoord_vol=coord_sommets(numso,2);
341 for (
int i = 0, numso2D; i < nse2D && (numso2D = le_domaine2D.
sommet_elem(ind_face, i)) >= 0; i++)
343 double xcoord_2D=coord_sommets_2D(numso2D,0);
344 double ycoord_2D=coord_sommets_2D(numso2D,1);
347 zcoord_2D=coord_sommets_2D(numso2D,2);
348 if ( est_egal(xcoord_vol,xcoord_2D)
349 && est_egal(ycoord_vol,ycoord_2D)
350 && est_egal(zcoord_vol,zcoord_2D))
357 if (coincide == nse_reel)
360 for (
int i=0; i<compteur ; i++)
361 if (les_faces[i]==numfa)
366 if (trouve==0) les_faces[compteur++] = numfa, face_tab(numfa) = 1;
374 const Groupe_Faces grp_faces = le_domaine.
groupe_faces(nom_surface);
375 int nb_faces = grp_faces.
nb_faces();
376 Cerr <<
"Face group " << nom_surface <<
" with " << nb_faces <<
" faces" << finl;
378 for (
int k=0; k < nb_faces; k++)
379 les_faces[k] = indice_faces[k], face_tab(indice_faces[k]) = 1;
383 trustIdType faces_found=mp_somme_vect(face_tab);
386 Cerr <<
"Error in Perte_Charge_Singuliere::lire_surfaces" << finl;
387 Cerr <<
"No faces has been found !" << finl;
391 Cerr <<
" " << faces_found <<
" faces have been found for the section." << finl;
393 les_faces.
resize(compteur);
396 sgn.resize(compteur);
398 for (
int i = 0; i < compteur; i++)
400 orientation->valeur_aux(xvf, ori);
401 for (
int i = 0; i < compteur; i++)
405 sgn(i) = (scal > 0 ? 1 : -1);
419 int cF = fac.dimension_tot(0) == 1, i, n, N = fac.line_size(), d, D =
Objet_U::dimension;
423 for (i = 0; i < num_faces.
size(); i++)
425 int f = num_faces(i), e = f_e(f, f_e(f, 0) < 0);
427 for (d = 0; d < D; d++)
428 for (n = 0; n < N; n++) deb_vect(f) += zvf.
face_normales(f, d) * vit(f, N * d + n) * fac(!cF * e, n);
429 else for (n = 0; n < N; n++) deb_vect(f) += fs(f) * vit(f, n) * fac(!cF * e, n);
430 deb_vect(f) *= pf(f) * (sgn.size() ? sgn(i) : deb_vect(f) > 0 ? 1 : -1) ;
432 return mp_somme_vect(deb_vect);
441 if (std::abs(deb_cible) > 1e-10)
443 const double alpha =
alpha_.eval(), error = (deb - deb_cible) / deb_cible;
444 K_ += dt * alpha * error;
448 if (!
Process::me()) bilan(0) =
K_, bilan(1) = deb, bilan(2) = deb_cible;
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Returns the array of field values at the current time.
virtual DoubleTab & valeurs()=0
const Sous_Domaine_t & ss_domaine(int i) const
Groupe_Faces_t & groupe_faces(int i)
int nb_som_elem() const
Returns the number of vertices of the geometric elements that make up the domain.
int_t nb_elem_tot() const
const OctreeRoot_t & construit_octree() const
void calculer_centres_gravite(DoubleTab_t &xp) const
Calculates the centers of gravity of the domain elements.
int nb_faces_elem(int=0) const
Returns the number of faces of type i of the geometric elements that make up the domain.
const DoubleTab_t & coord_sommets() const
int_t sommet_elem(int_t i, int j) const
Returns the (global) number of the j-th vertex of the i-th element.
virtual const DoubleVect & face_surfaces() const
void creer_tableau_faces(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
virtual double face_normales(int face, int comp) const
double xv(int num_face, int k) const
int face_sommets(int i, int j) const
Returns the index of the i-th vertex of face num_face.
int elem_faces(int i, int j) const
Returns the index of the i-th face of element num_elem; the face numbering convention is.
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
class Equation_base The role of an equation is the calculation of one or more fields....
virtual const Milieu_base & milieu() const =0
virtual const Champ_Inc_base & inconnue() const =0
Probleme_base & probleme()
Returns the problem associated with the equation.
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
int_t nb_faces() const
Returns the number of faces of the boundary.
const ArrOfInt_t & get_indices_faces() const
static Objet_U & objet(const Nom &)
See Interprete_bloc::objet_global(). BM: the Interprete class is not the best place for this.
DoubleVect & porosite_face()
A character string (Nom) in uppercase.
An array of Motcle objects.
int search(const Motcle &t) const
class Nom: a character string for naming TRUST objects.
virtual int debute_par(const char *const n) const
const Interprete & interprete() const
const Nom & que_suis_je() const
Returns the string identifying the class.
void rang_elems_sommet(SmallArrOfTID_t &, double x, double y=0, double z=0) const
Helper class to factorize the readOn method of Objet_U classes.
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
int lire_avec_accolades(Entree &is)
Alias of lire_avec_accolades_depuis.
Multiphase thermohydraulics problem of type "3*N equations":
void update_K(const Equation_base &eqn, double deb, DoubleVect &bilan)
double calculate_Q(const Equation_base &eqn, const IntVect &num_faces, const IntVect &sgn) const
virtual void lire_surfaces(Entree &, const Domaine &, const Domaine_dis_base &, IntVect &, IntVect &, int lire_derniere_accolade=1)
Entree & lire_donnees(Entree &)
Entree & lire_regul(Entree &)
Reads the specifications of a singular pressure drop from an input stream.
int direction_perte_charge_
int direction_perte_charge() const
Returns the pressure drop direction.
const Champ_base & get_champ(const Motcle &nom) const override
const Schema_Temps_base & schema_temps() const
Returns the time scheme associated with the problem.
static int me()
Returns the rank of the local processor in the current communication group. See Comm_Group::rank() an...
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
double temps_courant() const
Returns the current time.
double pas_de_temps() const
Returns the current time step (delta_t).
int_t nb_elem_tot() const
_SIZE_ size_array() const
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)