TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Source_Scalaire_EF.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 <Source_Scalaire_EF.h>
17#include <Champ_Uniforme.h>
18#include <Domaine.h>
19#include <Domaine_EF.h>
20#include <Probleme_base.h>
21#include <Discretisation_base.h>
22#include <Equation_base.h>
23
24//#include <Debog.h>
25
26//#include <Champ_couplage_primaire_secondaire.h>
27
28Implemente_instanciable(Source_Scalaire_EF,"Source_Scalaire_EF",Source_base);
29
30
31
32//// printOn
33//
34
36{
37 return s << que_suis_je() ;
38}
39
40
41//// readOn
42//
45{
46 s >> la_source_lu_;
47 const Probleme_base& pb =equation().probleme();
48
49 if (sub_type(Champ_Uniforme,la_source_lu_.valeur()))
50 {
51 la_source_.typer(la_source_lu_->que_suis_je());
52 la_source_.valeur()=la_source_lu_.valeur();
53 }
54// else if (sub_type(Champ_couplage_primaire_secondaire,la_source_lu_.valeur()))
55 else if (la_source_lu_->que_suis_je()=="Champ_couplage_primaire_secondaire")
56 {
57 la_source_=la_source_lu_;
58 }
59 else
60 {
61 equation().discretisation().discretiser_champ("champ_elem",equation().domaine_dis(),"source",",",1,0.,la_source_);
62 la_source_->affecter(la_source_lu_);
63 la_source_lu_.detach();
64 }
65 // const Equation_base& eqn = pb.equation(0);
66 equation().discretisation().nommer_completer_champ_physique(equation().domaine_dis(),"Puissance_volumique","W/m3",la_source_,pb);
67 champs_compris_.ajoute_champ(la_source_);
68 if (la_source_->nb_comp() != equation().inconnue().nb_comp())
69 {
70 Cerr << "Error reading the source term of type " << que_suis_je() << finl;
71 Cerr << "the source field must have " << equation().inconnue().nb_comp() << " components" << finl;
72 exit();
73 }
74
75 return s;
76}
77
79 const Domaine_Cl_dis_base& domaine_Cl_dis)
80{
81 le_dom_EF = ref_cast(Domaine_EF, domaine_dis);
82 // le_dom_Cl_EF = ref_cast(Domaine_Cl_EF, domaine_Cl_dis);
83}
84
85
86DoubleTab& Source_Scalaire_EF::ajouter(DoubleTab& resu) const
87{
88 const Domaine_EF& domaine_EF = le_dom_EF.valeur();
89 int ncomp=equation().inconnue().nb_comp();
90 const IntTab& elems= domaine_EF.domaine().les_elems() ;
91 int nb_som_elem=domaine_EF.domaine().nb_som_elem();
92 int nb_elems=domaine_EF.domaine().nb_elem_tot();
93
94 // Note: computation is IPhi *S(e)
95 // const DoubleTab& IPhi_thilde=domaine_EF.IPhi_thilde();
96
97 const DoubleTab& IPhi=domaine_EF.IPhi();
98
99 int is_source_unif=0;
100
101 if (sub_type(Champ_Uniforme,la_source_.valeur()))
102 is_source_unif=1;
103 const DoubleTab& tab_source=la_source_->valeurs();
104 if (ncomp>1)
105 for (int num_elem=0; num_elem<nb_elems; num_elem++)
106 for (int comp=0; comp<ncomp; comp++)
107 {
108 double source ;
109 int cc=0;
110 if (!is_source_unif) cc=num_elem;
111 source=tab_source(cc,comp);
112 for (int i=0; i<nb_som_elem; i++)
113 resu(elems(num_elem,i),comp)+=source*IPhi(num_elem,i);
114 }
115 else
116 {
117 for (int num_elem=0; num_elem<nb_elems; num_elem++)
118 {
119 double source ;
120
121 if (!is_source_unif)
122 source=tab_source(num_elem);
123 else
124 source=tab_source(0,0);
125 for (int i=0; i<nb_som_elem; i++)
126 resu(elems(num_elem,i))+=source*IPhi(num_elem,i);
127
128 }
129
130 }
131
132 return resu;
133}
134
135DoubleTab& Source_Scalaire_EF::calculer(DoubleTab& resu) const
136{
137 resu = 0;
138 return ajouter(resu);
139}
140
142{
143 la_source_->mettre_a_jour(temps);
144}
145
146
Champ_Uniforme Represents a field that is constant in space and time.
void nommer_completer_champ_physique(const Domaine_dis_base &domaine_vdf, const Nom &nom_champ, const Nom &unite, Champ_base &champ, const Probleme_base &pbi) const
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
int nb_som_elem() const
Returns the number of vertices of the geometric elements that make up the domain.
Definition Domaine.h:474
int_t nb_elem_tot() const
Definition Domaine.h:132
IntTab_t & les_elems()
Definition Domaine.h:129
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_EF
Definition Domaine_EF.h:56
const DoubleTab & IPhi() const
Definition Domaine_EF.h:91
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,...
Definition Entree.h:42
const Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
virtual const Champ_Inc_base & inconnue() const =0
Probleme_base & probleme()
Returns the problem associated with the equation.
virtual int nb_comp() const
Definition Field_base.h:56
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
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
class Probleme_base It is a Probleme_U that is not a coupling.
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
class Source_Scalaire_EF
void associer_domaines(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override
void associer_pb(const Probleme_base &) override
DoubleTab & calculer(DoubleTab &) const override
void mettre_a_jour(double) override
DOES NOTHING - to override in derived classes.
DoubleTab & ajouter(DoubleTab &) const override
Source_base A Source_base object is a term appearing on the right-hand side of an.
Definition Source_base.h:42
Champs_compris champs_compris_