TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Diff_PolyMAC_CDO_base.h
1/****************************************************************************
2* Copyright (c) 2025, 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#ifndef Op_Diff_PolyMAC_CDO_base_included
17#define Op_Diff_PolyMAC_CDO_base_included
18
19#include <Op_Diff_PolyMAC_CDO_Gen_base.h>
20#include <Op_Diff_Turbulent_base.h>
21#include <Domaine_PolyMAC_CDO.h>
22
24{
25 Declare_base(Op_Diff_PolyMAC_CDO_base);
26public:
27 double calculer_dt_stab() const override;
28
29 void completer() override;
30 void mettre_a_jour(double t) override
31 {
33 nu_a_jour_ = 0;
34 }
35
36 void update_nu() const override; // met a jour nu et nu_fac
37 const DoubleTab& get_nu() const { return nu_; }
38 const DoubleTab& get_nu_fac() const { return nu_fac_; }
39
40 inline void remplir_nu_ef(int e, DoubleTab& nu_ef) const;
41
42protected:
43 mutable DoubleTab nu_fac_mod; //user-defined multiplicative factor to apply to nu_fac
44 mutable DoubleTab nu_fac_; //conductivity at elements, multiplicative factor to apply per face
45};
46
47/* diffusivity inside element e: nu_ef(i, n): diffusivity of component n between the element center and that of face i */
48inline void Op_Diff_PolyMAC_CDO_base::remplir_nu_ef(int e, DoubleTab& nu_ef) const
49{
50 const Domaine_PolyMAC_CDO& domaine = le_dom_poly_.valeur();
51 const IntTab& e_f = domaine.elem_faces();
52 const DoubleTab& xp = domaine.xp(), &xv = domaine.xv();
53 int i, j, k, f, n, N = nu_ef.dimension(1), N_nu = nu_.line_size();
54 double fac;
55
56 for (i = 0; i < domaine.m2d(e + 1) - domaine.m2d(e); i++)
57 {
58 f = e_f(e, i);
59 /* diffusivity of each component in the direction (xf - xe) */
60 if (N_nu == N)
61 for (n = 0; n < N; n++)
62 nu_ef(i, n) = nu_(e, n); //isotrope
63 else if (N_nu == N * dimension)
64 for (n = 0; n < N; n++)
65 for (j = 0, nu_ef(i, n) = 0; j < dimension; j++) //anisotrope diagonal
66 nu_ef(i, n) += nu_.addr()[dimension * (N * e + n) + j] * std::pow(xv(f, j) - xp(e, j), 2);
67 else if (N_nu == N * dimension * dimension)
68 for (n = 0; n < N; n++)
69 for (j = 0, nu_ef(i, n) = 0; j < dimension; j++)
70 for (k = 0; k < dimension; k++)
71 nu_ef(i, n) += nu_.addr()[dimension * (dimension * (N * e + n) + j) + k] * (xv(f, j) - xp(e, j)) * (xv(f, k) - xp(e, k)); //anisotrope complet
72 else
73 abort();
74 for (n = 0, fac = nu_fac_.addr()[f] * (N_nu > N ? 1. / domaine.dot(&xv(f, 0), &xv(f, 0), &xp(e, 0), &xp(e, 0)) : 1); n < N; n++)
75 nu_ef(i, n) *= fac;
76 }
77}
78
79#endif /* Op_Diff_PolyMAC_CDO_base_included */
int elem_faces(int i, int j) const
Returns the index of the i-th face of element num_elem; the face numbering convention is.
Definition Domaine_VF.h:542
static int dimension
Definition Objet_U.h:94
class Op_Diff_PolyMAC_CDO_Gen_base
void remplir_nu_ef(int e, DoubleTab &nu_ef) const
void mettre_a_jour(double t) override
DOES NOTHING - to override in derived classes.
const DoubleTab & get_nu_fac() const
const DoubleTab & get_nu() const
double calculer_dt_stab() const override
Computes dt_stab.
void completer() override
Associates the operator with the domaine_dis, the domaine_Cl_dis, and the unknown of its equation.
Base class for diffusion operators in a turbulent flow.
virtual void mettre_a_jour(double temps)
DOES NOTHING - to override in derived classes.
static void abort()
Abort routine for TRUST on a fatal error.
Definition Process.cpp:573
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133