TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Senseur_Interface.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#include <Senseur_Interface.h>
16#include <Champ_base.h>
17#include <TRUSTTab.h>
18#include <Transport_Interfaces_FT_Disc.h>
19#include <Domaine.h>
20#include <Domaine_VF.h>
21#include <Probleme_base.h>
22#include <Param.h>
23
24Implemente_instanciable(Senseur_Interface, "Senseur_Interface", Objet_U);
25
27{
28 Param param(que_suis_je());
29 param.ajouter("equation_interface", &equation_interface_, Param::REQUIRED);
30 param.ajouter("segment_senseur_1", &segment_senseur_1_, Param::REQUIRED);
31 param.ajouter("segment_senseur_2", &segment_senseur_2_, Param::REQUIRED);
32 param.ajouter("nb_points_tests", &nb_points_tests_, Param::REQUIRED);
33 param.lire_avec_accolades_depuis(is);
34
35 const int dim = dimension;
36
37 if (segment_senseur_1_.size_array() != dim
38 || segment_senseur_2_.size_array() != dim
39 || nb_points_tests_ < 2)
40 {
41 Cerr << "Error: wrong segments dimension or nb_points_tests" << finl;
43 }
44 equation_ = ref_cast(Transport_Interfaces_FT_Disc, probleme_->get_equation_by_name(equation_interface_));
45
46 return is;
47}
48
50{
51 return os;
52}
53
54int Senseur_Interface::calculer_position(ArrOfDouble& pos) const
55{
56 int i, j;
57 int ok = 0;
58
59 const Transport_Interfaces_FT_Disc& eq = ref_cast(Transport_Interfaces_FT_Disc, equation_.valeur());
60 const Champ_base& indicatrice = eq.inconnue();
61 // Recherche de la position de l'interface:
62 const int dim = segment_senseur_1_.size_array();
63 DoubleTab positions(nb_points_tests_, dim);
64 const double facteur = 1. / (double)(nb_points_tests_-1.);
65 for (j = 0; j < dim; j++)
66 {
67 const double x1 = segment_senseur_1_[j];
68 const double x2 = segment_senseur_2_[j];
69 for (i = 0; i < nb_points_tests_; i++)
70 {
71 double t = ((double) i) * facteur;
72 positions(i,j) = x2 * t + x1 * (1. - t);
73 }
74 }
75 IntVect num_element(nb_points_tests_);
76 const Domaine& domaine = eq.domaine_dis().domaine();
77 domaine.chercher_elements(positions, num_element);
78 //DoubleVect dist(nb_points_tests_);
79 // Invalide le numero d'element pour les elements virtuels
80 const int nb_elem = domaine.nb_elem();
81 for (i = 0; i < nb_points_tests_; i++)
82 {
83 const int elem = num_element[i];
84 if (elem >= 0 && elem < nb_elem)
85 {
86 const double ind = indicatrice.valeurs()(elem);
87 if (ind > 0. && ind < 1.) // On a trouve l'interface !
88 break;
89 }
90 }
91 double t_injection; // Entre 0 et 1, coordonnee de l'interface le long du segment
92 const DoubleTab& xp = ref_cast(Domaine_VF, eq.domaine_dis()).xp();
93 // No need to update distance and normal, they are already up-to-date.
94 const DoubleTab& normale_interf = eq.get_normale_interface().valeurs();
95 const DoubleTab& distance_interf = eq.get_distance_interface().valeurs();
96 if (i < nb_points_tests_)
97 {
98 const int elem = num_element[i];
99 double s1s2_scal_n = 0.; // produit scalaire entre la normale unitaire a l'interface et le vecteur "segment"
100 double norme2_s1s2 = 0.;
101 double s1s2_scal_s1elem = 0.;
102 for (j = 0; j < dim; j++)
103 {
104 double s1s2 = segment_senseur_2_[j] - segment_senseur_1_[j];
105 s1s2_scal_n += s1s2 * normale_interf(elem, j);
106 norme2_s1s2 += s1s2 * s1s2;
107 s1s2_scal_s1elem += s1s2 * (xp(elem, j) - segment_senseur_1_[j]);
108 }
109 t_injection = s1s2_scal_s1elem / norme2_s1s2 - distance_interf(elem) / s1s2_scal_n;
110 }
111 else
112 {
113 t_injection = 1.e30;
114 }
115 // Quel processeur a trouve une maille avec l'interface ?
116 t_injection = mp_min(t_injection);
117 if (t_injection < 0.99e30)
118 {
119 pos.resize_array(dim);
120 for (i = 0; i < dim; i++)
121 {
122 const double x1 = segment_senseur_1_[i];
123 const double x2 = segment_senseur_2_[i];
124 const double x = x2 * t_injection + x1 * (1. - t_injection);
125 pos[i] = x;
126 ok = 1;
127 }
128 }
129 else
130 {
131 pos = segment_senseur_1_;
132 ok = 0;
133 }
134 return ok;
135}
virtual DoubleTab & valeurs()=0
classe Champ_base Cette classe est la base de la hierarchie des champs.
Definition Champ_base.h:43
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
class Domaine_VF
Definition Domaine_VF.h:44
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Domaine_dis_base & domaine_dis()
Renvoie le domaine discretise associe a l'equation.
classe Objet_U Cette classe est la classe de base des Objets de TRUST
Definition Objet_U.h:73
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
@ REQUIRED
Definition Param.h:115
static double mp_min(double)
Definition Process.cpp:386
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
virtual int calculer_position(ArrOfDouble &pos) const
ArrOfDouble segment_senseur_1_
ArrOfDouble segment_senseur_2_
Classe de base des flux de sortie.
Definition Sortie.h:52
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
const Champ_Inc_base & inconnue() const override
virtual const Champ_base & get_normale_interface() const
virtual const Champ_base & get_distance_interface() const