TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Ostwald_VEF.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 <Navier_Stokes_std.h>
17#include <Champ_Ostwald_VEF.h>
18#include <Champ_Uniforme.h>
19#include <Fluide_Ostwald.h>
20#include <Domaine_VEF.h>
21
22Implemente_instanciable(Champ_Ostwald_VEF, "Champ_Ostwald_VEF", Champ_Ostwald);
23
24Sortie& Champ_Ostwald_VEF::printOn(Sortie& os) const { return os << valeurs()(0, 0); }
25
26Entree& Champ_Ostwald_VEF::readOn(Entree& is) { return is; }
27
28/*! @brief @brief Update the parameter mu at the given time.
29 *
30 * @param (double) current time
31 */
38
39/*! @brief @brief Compute the viscosity mu as a function of the consistency and the structure index using the Ostwald law.
40 *
41 * For very low and very high viscosities, a regression is used.
42 *
43 * @param (DoubleTab&) viscosities at the previous time step
44 */
45
46void Champ_Ostwald_VEF::calculer_mu(DoubleTab& mu_tab)
47{
48 const double d_n = mon_fluide_->indice_struct().valeurs()(0, 0);
49
50 for (int i = 0; i < nb_valeurs_nodales(); i++)
51 {
52 if (sub_type(Champ_Uniforme, mon_fluide_->consistance()))
53 {
54 const double d_k = mon_fluide_->consistance().valeurs()(0, 0);
55 if (mu_tab[i] < 1.E-4)
56 mu_tab[i] = d_k * pow(0.5 * 1.E-4, (d_n - 1.) / 2.);
57 else if (mu_tab[i] > 1.E16)
58 mu_tab[i] = d_k * pow(0.5 * 1.E16, (d_n - 1.) / 2.);
59 else
60 mu_tab[i] = d_k * pow(0.5 * mu_tab[i], (d_n - 1.) / 2.);
61 }
62 else // K varies as a function of temperature
63 {
64 const DoubleTab& K_tab = mon_fluide_->consistance().valeurs();
65 if (mu_tab[i] < 1.E-4)
66 mu_tab[i] = K_tab[i] * pow(0.5 * 1.E-4, (d_n - 1.) / 2.);
67 else if (mu_tab[i] > 1.E16)
68 mu_tab[i] = K_tab[i] * pow(0.5 * 1.E16, (d_n - 1.) / 2.);
69 else
70 mu_tab[i] = K_tab[i] * pow(0.5 * mu_tab[i], (d_n - 1.) / 2.);
71 }
72 }
73}
74
76{
77 eq_hydraulique = ref_cast(Navier_Stokes_std, eq);
78}
79
81{
82 const Domaine_VEF& domaine_VEF = ref_cast(Domaine_VEF,domaine_vf());
83 const Domaine_Cl_VEF& zcl_VEF = ref_cast(Domaine_Cl_VEF, eq_hydraulique->domaine_Cl_dis());
84 const DoubleTab& vit = eq_hydraulique->inconnue().valeurs();
85 int nb_elem = domaine_VEF.nb_elem();
86 int nb_elem_tot = domaine_VEF.nb_elem_tot();
87
88 int elem;
89
90 DoubleTab gradient_elem(nb_elem_tot, dimension, dimension);
91 Champ_P1NC::calcul_gradient(vit, gradient_elem, zcl_VEF);
92
93 if (dimension == 2)
94 for (elem = 0; elem < nb_elem; elem++)
95 {
96 dscald(elem) = 4. * (gradient_elem(elem, 0, 0) * gradient_elem(elem, 0, 0) + gradient_elem(elem, 1, 1) * gradient_elem(elem, 1, 1))
97 + 2. * ((gradient_elem(elem, 0, 1) + gradient_elem(elem, 1, 0)) * (gradient_elem(elem, 0, 1) + gradient_elem(elem, 1, 0)));
98 }
99 else if (dimension == 3)
100 for (elem = 0; elem < nb_elem; elem++)
101 {
102 dscald(elem) = 4. * (gradient_elem(elem, 0, 0) * gradient_elem(elem, 0, 0) + gradient_elem(elem, 1, 1) * gradient_elem(elem, 1, 1) + gradient_elem(elem, 2, 2) * gradient_elem(elem, 2, 2))
103 + 2.
104 * (((gradient_elem(elem, 0, 1) + gradient_elem(elem, 1, 0)) * (gradient_elem(elem, 0, 1) + gradient_elem(elem, 1, 0)))
105 + ((gradient_elem(elem, 2, 0) + gradient_elem(elem, 0, 2)) * (gradient_elem(elem, 2, 0) + gradient_elem(elem, 0, 2)))
106 + ((gradient_elem(elem, 2, 1) + gradient_elem(elem, 1, 2)) * (gradient_elem(elem, 2, 1) + gradient_elem(elem, 1, 2))));
107 }
108}
109
110/*! @brief @brief Compute the Ostwald field: compute D::D then compute mu.
111 *
112 * @param (double) time at which the computation is performed
113 */
114
116{
117 if (temps_ != tps)
118 {
121 }
122}
123
124/*! @brief @brief Initialize the field.
125 *
126 */
127void Champ_Ostwald_VEF::init_mu(DoubleTab& mu_tab)
128{
129 const DoubleTab& K_tab = mon_fluide_->consistance().valeurs();
130 for (int i = 0; i < nb_valeurs_nodales(); i++) mu_tab[i] = K_tab[i];
131}
132
133int Champ_Ostwald_VEF::initialiser(const double un_temps)
134{
135 mettre_a_jour(un_temps);
136 return 1;
137}
void mettre_a_jour(double temps) override
Time update.
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
int nb_valeurs_nodales() const override
Returns the number of degrees of freedom per component: the number of nodes.
virtual const Domaine_VF & domaine_vf() const
class Champ_Ostwald_VEF
void calculer_mu(DoubleTab &)
Compute the viscosity mu as a function of the consistency and the structure index using the Ostwald l...
void init_mu(DoubleTab &)
Initialize the field.
int initialiser(const double temps) override
DOES NOTHING.
void associer_eqn(const Navier_Stokes_std &)
void me_calculer(double tps) override
Compute the Ostwald field: compute D::D then compute mu.
void calculer_dscald(DoubleTab &)
void mettre_a_jour(double temps) override
Update the parameter mu at the given time.
Champ_Ostwald Represents a field that varies as a function of consistency and.
static DoubleTab & calcul_gradient(const DoubleTab &, DoubleTab &, const Domaine_Cl_VEF &)
Champ_Uniforme Represents a field that is constant in space and time.
double temps_
Definition Champ_base.h:123
virtual double changer_temps(const double t)
Sets the time at which the field is defined.
class Domaine_VEF
Definition Domaine_VEF.h:53
int nb_elem_tot() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Navier_Stokes_std This class carries the terms of the momentum equation.
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
Base class for output streams.
Definition Sortie.h:52