TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Diff_EF_base.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 <Op_Diff_EF_base.h>
17#include <Champ_Uniforme.h>
18#include <Milieu_base.h>
19#include <Probleme_base.h>
20#include <Schema_Temps_base.h>
21#include <Domaine_EF.h>
22#include <Domaine_Cl_EF.h>
23#include <Champ_Fonc_P0_base.h>
24#include <Domaine.h>
25
26Implemente_base_sans_constructeur(Op_Diff_EF_base,"Op_Diff_EF_base",Operateur_Diff_base);
27
28Op_Diff_EF_base::Op_Diff_EF_base()
29{
31}
32
33//// printOn
34//
35
37{
38 return s << que_suis_je() ;
39}
40
41
42//// readOn
43//
44
46{
47 return s ;
48}
49
51{
52 return Op_EF_base::impr(os, *this);
53}
54
56 const Domaine_Cl_dis_base& domaine_cl_dis,
57 const Champ_Inc_base& ch_transporte)
58{
59
60 const Domaine_EF& zEF = ref_cast(Domaine_EF,domaine_dis);
61 const Domaine_Cl_EF& zclEF = ref_cast(Domaine_Cl_EF,domaine_cl_dis);
62
63 le_dom_EF = zEF;
64 la_zcl_EF = zclEF;
65 inconnue = ch_transporte;
66
67 const Domaine_EF& domaine_EF = le_dom_EF.valeur();
68
69 int nb_comp = 1;
70
71 flux_bords_.resize(domaine_EF.nb_faces_bord(),nb_comp);
72 flux_bords_=0.;
73}
75{
77 // The diffusivity is constant over the domain, so
78 //
79 // dt_diff = h*h/diffusivity
80
81 double dt_stab = DMAXFLOAT;
82 const Domaine_EF& domaine_EF = le_dom_EF.valeur();
84 {
85 if (1)
86 {
87 // "Standard" method for computing the time step.
88 // This estimate is very conservative: if the max of the diffusivity
89 // is not reached where the min of delta_h_squared is reached,
90 // the time step is underestimated.
91 const Champ_base& champ_diffusivite = diffusivite_pour_pas_de_temps();
92 const DoubleVect& valeurs_diffusivite = champ_diffusivite.valeurs();
93 double alpha_max = local_max_vect(valeurs_diffusivite);
94
95 if ((alpha_max == 0.)||(domaine_EF.nb_elem()==0))
96 dt_stab = DMAXFLOAT;
97 else
98 {
99 const double min_delta_h_carre = domaine_EF.carre_pas_du_maillage();
100 dt_stab = min_delta_h_carre / (2. * dimension * alpha_max);
101 }
102 }
103 else
104 {
105 const Domaine_EF& domaine_ef=ref_cast(Domaine_EF,equation().domaine_dis());
106 const DoubleTab& coord=domaine_ef.domaine().les_sommets();
107 const IntTab& elems=domaine_ef.domaine().les_elems() ;
108 const Champ_base& champ_diffusivite = diffusivite_pour_pas_de_temps();
109 const DoubleVect& valeurs_diffusivite = champ_diffusivite.valeurs();
110 const int nb_elem = domaine_EF.nb_elem();
111 int elem;
112 // Variable density field.
113 for (elem = 0; elem < nb_elem; elem++)
114 {
115
116 const double diffu = valeurs_diffusivite(elem)+DMINFLOAT;
117 double dx2=0,dl;
118 for (int d=0; d<3; d++)
119 {
120 dl=coord(elems(elem,0),d)-coord(elems(elem,7),d);
121 dx2+=(dl*dl);
122 }
123 const double dt = dx2 / diffu;
124 if (dt_stab > dt)
125 {
126 dt_stab = dt;
127 // Cerr<<" ii "<<elem<<" "<<diffu<<" "<<dx2<<finl;
128 }
129 }
130 }
131 }
132 else
133 {
134 const double deux_dim = 2. * Objet_U::dimension;
135 const Champ_base& champ_diffu = diffusivite();
136 const DoubleTab& valeurs_diffu = champ_diffu.valeurs();
137 const Champ_base& champ_rho = get_champ_masse_volumique();
138 const DoubleTab& valeurs_rho = champ_rho.valeurs();
139 assert(sub_type(Champ_Fonc_P0_base, champ_rho));
140 assert(sub_type(Champ_Fonc_P0_base, champ_diffu));
141 const int nb_elem = domaine_EF.nb_elem();
142 int elem;
143 // Variable density field.
144 for (elem = 0; elem < nb_elem; elem++)
145 {
146 const double h_carre = domaine_EF.carre_pas_maille(elem);
147 const double diffu = valeurs_diffu(elem);
148 const double rho = valeurs_rho(elem);
149 const double dt = h_carre * rho / (deux_dim * diffu);
150 if (dt_stab > dt)
151 dt_stab = dt;
152 }
153 }
154 dt_stab = Process::mp_min(dt_stab);
155 return dt_stab;
156}
Class Champ_Inc_base.
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
DoubleTab_t & les_sommets()
Definition Domaine.h:113
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
double carre_pas_maille(int i) const
Definition Domaine_EF.h:70
double carre_pas_du_maillage() const
Definition Domaine_EF.h:69
int nb_faces_bord() const
Returns the number of faces on which boundary conditions are applied:
Definition Domaine_VF.h:512
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 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
friend class Sortie
Definition Objet_U.h:70
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 Op_Diff_EF_base Base class for EF diffusion operators.
double calculer_dt_stab() const override
Computes dt_stab.
void associer(const Domaine_dis_base &, const Domaine_Cl_dis_base &, const Champ_Inc_base &) override
int impr(Sortie &os) const override
DOES NOTHING - to override in derived classes.
virtual void remplir_nu(DoubleTab &) const =0
int impr(Sortie &, const Operateur_base &) const
Prints the boundary fluxes of an EF operator at faces (i.e., diffusion, convection).
Operateur_Diff_base This class is the base of the hierarchy of operators representing.
virtual const Champ_base & diffusivite() const =0
virtual const Champ_base & diffusivite_pour_pas_de_temps() const
Returns the field corresponding to the true diffusivity of the medium used for the time step computat...
DoubleTab flux_bords_
static double mp_min(double)
Definition Process.cpp:391
Base class for output streams.
Definition Sortie.h:52
virtual const Champ_base & get_champ_masse_volumique() const
Returns the density field.
virtual void declare_support_masse_volumique(int ok)
The constructor of a derived class that uses the density field must call this function with the value...
virtual int has_champ_masse_volumique() const
Returns 1 if the density field has been associated, 0 otherwise.