TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Source_Reaction_Particules_VEF.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 <Source_Reaction_Particules_VEF.h>
17#include <TRUSTTab.h>
18#include <Transport_Marqueur_FT.h>
19#include <Domaine.h>
20#include <Domaine_VF.h>
21#include <Champ_implementation_P1.h>
22#include <Dirichlet.h>
23#include <Dirichlet_homogene.h>
24#include <Milieu_base.h>
25#include <Scatter.h>
26#include <Echange_EV_Options.h>
27#include <MD_Vector_tools.h>
28#include <Probleme_base.h>
29
30Implemente_instanciable(Source_Reaction_Particules_VEF,"Two_Way_Coupling_VEF",Source_Reaction_Particules);
31
32
34{
35 return os;
36}
37
39{
40 return is;
41}
42
43//-Interpolation de source_stockage_ aux sommets (par ponderation par coordonnes barycentriques)
44//-Dans le cas parallele une sommation aux sommets items communs est faite
45// pour tenir compte des contributions de chaque processeur
46//-Calcul de la source aux faces en sommant la condribution de chacun des sommets de la face
47//Rq : Le terme source est divisee par rho si le milieu n est pas quasi-compressible
48DoubleTab& Source_Reaction_Particules_VEF::ajouter(DoubleTab& resu) const
49{
50 const DoubleTab& source_action = eq_marqueur_->source_stockage();
51 const Domaine_dis_base& zdis = equation().domaine_dis();
52 const Domaine_VF& zvf = ref_cast(Domaine_VF,zdis);
54 const Domaine& domaine_geom = zdis.domaine();
55 const DoubleTab& coord = domaine_geom.coord_sommets();
56 const IntTab& sommet_poly = domaine_geom.les_elems();
57 const IntTab& face_som = zvf.face_sommets();
58 const Maillage_FT_Disc& maillage = eq_marqueur_->maillage_interface();
59 const DoubleTab& positions = maillage.sommets();
60 const ArrOfInt& som_elem = maillage.sommet_elem();
61 int dim = Objet_U::dimension;
62 int nb_faces = zvf.nb_faces();
63 int premiere_face_interne = zvf.premiere_face_int();
64 int nb_pos = positions.dimension(0);
65 int nb_som_elem = domaine_geom.nb_som_elem();
66 int nb_som_face = domaine_geom.type_elem()->nb_som_face();
67 int is_QC=0;
68 int is_FT=0;
69 double coord_b=0.;
70 double x_pos,y_pos;
71 double z_pos=0.;
72 int elem,som_glob;
73 const int nb_elem_reels = domaine_geom.nb_elem();
74
75
76 //creation d un espace virtuel pour source_som
77 DoubleTab source_som(0, dim);
78 domaine_geom.creer_tableau_sommets(source_som);
79
80 //is_QC=0 le terme source est homogne a dv/dt sinon homogene a d(rho*v)/dt
81 is_QC = equation().probleme().is_dilatable();
82 if (sub_type(Navier_Stokes_FT_Disc,equation()))
83 is_FT = 1;
84
85 const Champ_base& champ_rho = (is_FT==1?ref_cast(Navier_Stokes_FT_Disc,equation()).champ_rho_faces():equation().milieu().masse_volumique());
86 const DoubleTab& rho_faces = champ_rho.valeurs();
87
88 //Remplissage de source_som (interpolation de source_stockage aux sommets)
89
90 //verifier que 0<=coord_b<=1
91 for (int pos=0; pos<nb_pos; pos++)
92 {
93 x_pos = positions(pos,0);
94 y_pos = positions(pos,1);
95 if (dim==3)
96 z_pos = positions(pos,2);
97
98 elem = som_elem[pos];
99 // On va sommer les contributions de tous les sommets communs,
100 // ne pas traiter les elements virtuels, on aurait plusieurs fois la contribution du meme point
101 if (elem < nb_elem_reels)
102 {
103 for (int som=0; som<nb_som_elem; som++)
104 {
105 som_glob = sommet_poly(elem,som);
106 if (dim==2)
107 coord_b = coord_barycentrique_P1_triangle(sommet_poly,coord,x_pos,y_pos,elem,som) ;
108 else if (dim==3)
109 coord_b = coord_barycentrique_P1_tetraedre(sommet_poly,coord,x_pos,y_pos,z_pos,elem,som) ;
110
111 for (int k=0; k<dim; k++)
112 source_som(som_glob,k) -= source_action(pos,k)*coord_b;
113 }
114 }
115 }
116
117 // Sommation des contributions de tous les sommets partages entre plusieurs processeurs,
118 // puis echange espace virtuel.
120
121 //Remplissage de resu (Interpolation de source_som aux faces)
122
123 //Traitement des conditions limites
124 int num_cl;
125 for (num_cl=0 ; num_cl<zdis.nb_front_Cl() ; num_cl++)
126 {
127 const Cond_lim& la_cl = zcldis.les_conditions_limites(num_cl);
128 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
129 int ndeb = le_bord.num_premiere_face();
130 int nfin = ndeb + le_bord.nb_faces();
131 if (sub_type(Dirichlet,la_cl.valeur()) || sub_type(Dirichlet_homogene,la_cl.valeur()))
132 ;
133 else
134 for (int face=ndeb ; face<nfin ; face++)
135 {
136 double rho = 1.;
137 if (!is_QC)
138 rho = (is_FT==1?rho_faces(face):rho_faces(0,0));
139 for (int nbsf=0; nbsf<nb_som_face; nbsf++)
140 {
141 som_glob = face_som(face,nbsf);
142 for (int k=0; k<dim; k++)
143 resu(face,k) += (1./nb_som_face)*source_som(som_glob,k)/rho;
144 }
145 }
146 }
147
148 //Traitement des faces internes
149 for (int face=premiere_face_interne; face<nb_faces; face++)
150 {
151 double rho = 1.;
152 if (!is_QC)
153 rho = (is_FT==1?rho_faces(face):rho_faces(0,0));
154
155 for (int nbsf=0; nbsf<nb_som_face; nbsf++)
156 {
157 som_glob = face_som(face,nbsf);
158 for (int k=0; k<dim; k++)
159 resu(face,k) += (1./nb_som_face)*source_som(som_glob,k)/rho;
160 }
161 }
162
163 return resu;
164}
165
166
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
Classe Dirichlet_homogene This class is the base class of the hierarchy of homogeneous Dirichlet-type...
Dirichlet This class is the base class of the hierarchy of Dirichlet-type boundary conditions.
Definition Dirichlet.h:31
int nb_som_elem() const
Returns the number of vertices of the geometric elements that make up the domain.
Definition Domaine.h:474
IntTab_t & les_elems()
Definition Domaine.h:129
int_t nb_elem() const
Definition Domaine.h:131
const DoubleTab_t & coord_sommets() const
Definition Domaine.h:112
virtual void creer_tableau_sommets(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
Creates an array with one "row" per mesh vertex.
Definition Domaine.cpp:999
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
class Domaine_VF
Definition Domaine_VF.h:44
int nb_faces() const
Returns the total number of faces.
Definition Domaine_VF.h:471
int face_sommets(int i, int j) const
Returns the index of the i-th vertex of face num_face.
Definition Domaine_VF.h:582
int premiere_face_int() const
A face is internal if and only if it separates two elements.
Definition Domaine_VF.h:463
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
int nb_front_Cl() const
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Milieu_base & milieu() const =0
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
Probleme_base & probleme()
Returns the problem associated with the equation.
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_premiere_face() const
Definition Front_VF.h:63
static void echange_espace_virtuel(IntVect &, Operations_echange opt=ECHANGE_EV, IsExchangeBlocking is_exchange_blocking=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")
: class Maillage_FT_Disc Cette classe decrit un maillage:
const DoubleTab & sommets() const
renvoie le tableau des sommets (reels et virtuels) dimension(0) = nombre de sommets,
const ArrOfInt & sommet_elem() const
pour postraitement, renvoie sommet_elem_
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
static int dimension
Definition Objet_U.h:94
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
bool is_dilatable() const
Base class for output streams.
Definition Sortie.h:52
Classe Source_Reaction_Particules_VEF.
DoubleTab & ajouter(DoubleTab &) const override
Classe Source_Reaction_Particules Calcul du terme source a ajouter dans Navier_Stokes pour prendre en...
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133