TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Terme_Source_Qdm_Face_PolyMAC_CDO.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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 <Terme_Source_Qdm_Face_PolyMAC_CDO.h>
17#include <Neumann_sortie_libre.h>
18#include <Domaine_Cl_PolyMAC_family.h>
19#include <Neumann_homogene.h>
20#include <Domaine_PolyMAC_CDO.h>
21#include <Champ_Uniforme.h>
22
23#include <Equation_base.h>
24#include <Milieu_base.h>
25#include <Neumann.h>
26
27Implemente_instanciable(Terme_Source_Qdm_Face_PolyMAC_CDO, "Source_Qdm_face_PolyMAC_CDO", Source_base);
28
30
32{
33 s >> la_source;
34 if (la_source->nb_comp() != equation().inconnue().nb_comp())
35 {
36 Cerr << "Error reading the source term of type " << que_suis_je() << finl;
37 Cerr << "the source field must have " << dimension << " components" << finl;
39 }
40 return s ;
41}
42
44{
45 le_dom_PolyMAC_CDO = ref_cast(Domaine_PolyMAC_CDO, domaine_dis);
46 le_dom_Cl_PolyMAC_CDO = ref_cast(Domaine_Cl_PolyMAC_family, domaine_Cl_dis);
47}
48
49DoubleTab& Terme_Source_Qdm_Face_PolyMAC_CDO::ajouter(DoubleTab& resu) const
50{
51 if (has_interface_blocs()) return Source_base::ajouter(resu);
52
53 const Domaine_PolyMAC_CDO& domaine_PolyMAC_CDO = le_dom_PolyMAC_CDO.valeur();
54 const Domaine_Cl_PolyMAC_family& Domaine_Cl_PolyMAC_family = le_dom_Cl_PolyMAC_CDO.valeur();
55
56 /* 1. boundary faces: contribute only to Neumann faces */
57 for (int n_bord = 0; n_bord < domaine_PolyMAC_CDO.nb_front_Cl(); n_bord++)
58 {
60 if (!sub_type(Neumann, la_cl.valeur()) && !sub_type(Neumann_homogene, la_cl.valeur()) && !sub_type(Neumann_val_ext, la_cl.valeur()))
61 continue;
62 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
63 for (int f = le_bord.num_premiere_face(); f < le_bord.num_premiere_face() + le_bord.nb_faces(); f++)
64 {
65 int e = domaine_PolyMAC_CDO.face_voisins(f, 0);
66 double fac = equation().milieu().porosite_face(f) * domaine_PolyMAC_CDO.face_surfaces(f);
67 for (int r = 0; r < dimension; r++)
68 resu(f) += fac * la_source->valeurs()(sub_type(Champ_Uniforme,la_source.valeur()) ? 0 : e, r) * (domaine_PolyMAC_CDO.xv(f, r) - domaine_PolyMAC_CDO.xp(e, r));
69 }
70 }
71 /* 2. internal faces -> upstream/downstream contributions */
72 for (int f = domaine_PolyMAC_CDO.premiere_face_int(); f < domaine_PolyMAC_CDO.nb_faces(); f++)
73 {
74 double fac = equation().milieu().porosite_face(f) * domaine_PolyMAC_CDO.face_surfaces(f);
75 for (int i = 0; i < 2; i++)
76 for (int r = 0, e = domaine_PolyMAC_CDO.face_voisins(f, i); r < dimension; r++)
77 resu(f) += fac * la_source->valeurs()(sub_type(Champ_Uniforme,la_source.valeur()) ? 0 : e, r) * (domaine_PolyMAC_CDO.xv(f, r) - domaine_PolyMAC_CDO.xp(e, r)) * (i ? -1 : 1);
78 }
79 return resu;
80}
81
82DoubleTab& Terme_Source_Qdm_Face_PolyMAC_CDO::calculer(DoubleTab& resu) const
83{
84 resu = 0.;
85 return ajouter(resu);
86}
87
89{
90 la_source->mettre_a_jour(temps);
91}
Champ_Uniforme Represents a field that is constant in space and time.
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
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.
virtual const DoubleVect & face_surfaces() const
Definition Domaine_VF.h:51
int nb_faces() const
Returns the total number of faces.
Definition Domaine_VF.h:471
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
double xp(int num_elem, int k) const
Definition Domaine_VF.h:77
int premiere_face_int() const
A face is internal if and only if it separates two elements.
Definition Domaine_VF.h:463
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
int nb_front_Cl() 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
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
DoubleVect & porosite_face()
Definition Milieu_base.h:62
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
Classe Neumann_homogene This class is the base class of the hierarchy of homogeneous Neumann-type bou...
Classe Neumann_val_ext This class is the base class of the hierarchy of.
Classe Neumann This class is the base class of the hierarchy of Neumann-type boundary conditions.
Definition Neumann.h:31
static int dimension
Definition Objet_U.h:94
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
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
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
Source_base A Source_base object is a term appearing on the right-hand side of an.
Definition Source_base.h:42
virtual int has_interface_blocs() const
Definition Source_base.h:68
virtual DoubleTab & ajouter(DoubleTab &) const
void mettre_a_jour(double) override
DOES NOTHING - to override in derived classes.
DoubleTab & ajouter(DoubleTab &) const override
DoubleTab & calculer(DoubleTab &) const override
void associer_domaines(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override