TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Fonc_Elem_PolyMAC_MPFA_TC.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 <Champ_Fonc_Elem_PolyMAC_MPFA_TC.h>
17#include <grad_Champ_Face_PolyMAC_MPFA.h>
18#include <Navier_Stokes_std.h>
19#include <Domaine_Cl_PolyMAC_family.h>
20
21
22Implemente_instanciable(Champ_Fonc_Elem_PolyMAC_MPFA_TC, "Champ_Fonc_Elem_PolyMAC_MPFA_TC", Champ_Fonc_Elem_PolyMAC_CDO);
23
24Sortie& Champ_Fonc_Elem_PolyMAC_MPFA_TC::printOn(Sortie& s) const { return s << que_suis_je() << " " << le_nom(); }
25
27
33
34void Champ_Fonc_Elem_PolyMAC_MPFA_TC::me_calculer(double tps) //See Pope 2000 page 367 for ref
35{
36 const Champ_Face_PolyMAC_MPFA& vitesse = ref_cast(Champ_Face_PolyMAC_MPFA, champ_.valeur());
37 const Domaine_PolyMAC_MPFA& domaine = ref_cast(Domaine_PolyMAC_MPFA, vitesse.domaine_vf());
38 int e, d_U, d_X, n;
39 int D = dimension, N = champ_a_deriver().valeurs().line_size();
40 int ne = domaine.nb_elem(), nf_tot = domaine.nb_faces_tot();
41
42 const Navier_Stokes_std& eq = ref_cast(Navier_Stokes_std, vitesse.equation());
43 DoubleTab& tab_tc = valeurs();
44 const grad_Champ_Face_PolyMAC_MPFA& grad = ref_cast(grad_Champ_Face_PolyMAC_MPFA, eq.get_champ("gradient_vitesse"));
45 const DoubleTab& tab_grad = grad.valeurs();
46
47 for (e = 0; e < ne; e++)
48 for (n = 0; n < N; n++)
49 {
50 tab_tc(e, n) = 0;
51 for (d_U = 0; d_U < D; d_U++)
52 for (d_X = 0; d_X < D; d_X++)
53 {
54 double Sij = 0.5 * (tab_grad(nf_tot + d_X + e * D, D * n + d_U) + tab_grad(nf_tot + d_U + e * D, D * n + d_X));
55 if (d_U == d_X)
56 for (int i = 0; i < D; i++)
57 Sij += -1. / D * tab_grad(nf_tot + i + e * D, D * n + i); // Substract the divergence : this term is zero in incompressible NS
58 tab_tc(e, n) += Sij * Sij;
59 }
60 tab_tc(e, n) = sqrt(2 * tab_tc(e, n));
61 }
62
64}
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
: class Champ_Face_PolyMAC_MPFA
class Champ_Fonc_Elem_PolyMAC_MPFA_TC for the calculation of the shear rate
virtual Champ_Face_PolyMAC_MPFA & champ_a_deriver()
void mettre_a_jour(double) override
Time update of the field.
virtual const Domaine & domaine() const
void mettre_a_jour(double temps) override
Time update of the field.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
const Domaine_VF & domaine_vf() const
double temps() const
Returns the time of the field.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & le_nom() const override
Returns the name of the field.
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
Navier_Stokes_std This class carries the terms of the momentum equation.
const Champ_base & get_champ(const Motcle &nom) const override
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
Base class for output streams.
Definition Sortie.h:52
int line_size() const
Definition TRUSTVect.tpp:67
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")
class grad_Champ_Face_PolyMAC_MPFA for the calculation of the gradient.