TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Champ_Face_PolyMAC_MPFA.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 Champ_Face_PolyMAC_MPFA_included
17#define Champ_Face_PolyMAC_MPFA_included
18
19#include <Champ_Face_PolyMAC_HFV.h>
20#include <Domaine_PolyMAC_MPFA.h>
21#include <SolveurSys.h>
22
23/*! @brief : class Champ_Face_PolyMAC_MPFA
24 *
25 * Champ correspondant a une inconnue decrite par ses tangentes aux faces duales (ligne amont-aval, type vitesse)
26 * Les flux aux faces sont accessibles par les methodes valeurs_normales(), avec synchro automatique
27 * Degres de libertes : composantes tangentielles aux faces duales
28 *
29 *
30 */
31
33{
34 Declare_instanciable(Champ_Face_PolyMAC_MPFA) ;
35
36public :
37 inline const Domaine_PolyMAC_MPFA& domaine_PolyMAC_MPFA() const { return ref_cast(Domaine_PolyMAC_MPFA, le_dom_VF.valeur()); }
38
39 int fixer_nb_valeurs_nodales(int n) override;
40 void init_auxiliary_variables() override; /* demande l'ajout des variables auxiliaires (\vec v aux elements) */
41 int reprendre(Entree& fich) override;
42
43 DoubleTab& valeur_aux_elems(const DoubleTab& positions, const IntVect& polys, DoubleTab& result) const override;
44 DoubleTab& valeur_aux_elems_passe(const DoubleTab& positions, const IntVect& polys, DoubleTab& result) const override;
45 DoubleVect& valeur_aux_elems_compo(const DoubleTab& positions, const IntVect& polys, DoubleVect& result, int ncomp) const override;
46 DoubleTab& trace(const Frontiere_dis_base& , DoubleTab& , double, int distant ) const override;
47
48 Champ_base& affecter_(const Champ_base& ) override;
49
50 //interpolations vitesse aux faces -> vitesse aux elems
51 void update_ve(DoubleTab& val) const; //ordre 1
52
53 void init_ve2() const; //ordre 2 -> avec une matrice
54 mutable IntTab ve2d, ve2j, ve2bj;
55 mutable DoubleTab ve2c, ve2bc;
56 void update_ve2(DoubleTab& val, int incr = 0) const;
57
58 /* utilitaire pour le calcul des termes sources : calcule le vecteur v_e + n_f (v_f - v_e. n_f)
59 retour : le vecteur, sa norme et les derivees de celle-ci selon v_e et v_f
60 */
61 inline double v_norm(const DoubleTab& val, const DoubleTab& val_f, int e, int f, int k, int l, double *v_ext, double *dnv) const
62 {
64 int d, D = dimension, nf_tot = domaine.nb_faces_tot();
65 const DoubleTab& nf = domaine.face_normales();
66 const DoubleVect& fs = domaine.face_surfaces();
67 double scal = 0, vf = f >= 0 ? val_f(f, k) - (l >= 0 ? val_f(f, l) : 0) : 0, v_temp[3], *v = v_ext ? v_ext : v_temp;
68 for (d = 0; d < D; d++) v[d] = val(nf_tot + D * e + d, k) - (l >= 0 ? val(nf_tot + D * e + d, l) : 0);
69 if (f >= 0)
70 for (d = 0, scal = domaine.dot(v, &nf(f, 0)) / fs(f); d < D; d++) v[d] += (vf - scal) * nf(f, d) / fs(f);
71 double nv = sqrt(domaine.dot(v, v));
72 if (dnv)
73 for (d = 0; d < D; d++) dnv[d] = nv ? (v[d] - (f >= 0 ? vf * nf(f, d) / fs(f) : 0)) / nv : 0;
74#ifdef _COMPILE_AVEC_PGCC
75 if (dnv) dnv[3] = f >= 0 && nv ? vf / (nv+DMINFLOAT) : 0; // nvc++ sucks
76#else
77 if (dnv) dnv[3] = f >= 0 && nv ? vf / nv : 0;
78#endif
79 return nv;
80 }
81private:
82 DoubleTab& valeur_aux_elems_(const DoubleTab& val_face ,const DoubleTab& positions, const IntVect& les_polys, DoubleTab& valeurs) const override;
83};
84
85#endif /* Champ_Face_PolyMAC_MPFA_included */
: class Champ_Face_PolyMAC_HFV
: class Champ_Face_PolyMAC_MPFA
Champ_base & affecter_(const Champ_base &) override
const Domaine_PolyMAC_MPFA & domaine_PolyMAC_MPFA() const
DoubleTab & trace(const Frontiere_dis_base &, DoubleTab &, double, int distant) const override
Calcule la trace d'un champ sur une frontiere au temps tps.
DoubleTab & valeur_aux_elems_passe(const DoubleTab &positions, const IntVect &polys, DoubleTab &result) const override
double v_norm(const DoubleTab &val, const DoubleTab &val_f, int e, int f, int k, int l, double *v_ext, double *dnv) const
int fixer_nb_valeurs_nodales(int n) override
DoubleVect & valeur_aux_elems_compo(const DoubleTab &positions, const IntVect &polys, DoubleVect &result, int ncomp) const override
provoque une erreur ! doit etre surchargee par les classes derivees
DoubleTab & valeur_aux_elems(const DoubleTab &positions, const IntVect &polys, DoubleTab &result) const override
provoque une erreur ! doit etre surchargee par les classes derivees
void update_ve(DoubleTab &val) const
Interpolates face-based velocity to element centers using a first-order method.
void init_ve2() const
Initializes second-order interpolation coefficients from faces to element centers.
int reprendre(Entree &fich) override
Reprise d'un Objet_U sur un flot d'entree Methode a surcharger.
void update_ve2(DoubleTab &val, int incr=0) const
Applies the second-order interpolation from face velocities to element centers.
const Domaine & domaine() const
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
classe Champ_base Cette classe est la base de la hierarchie des champs.
Definition Champ_base.h:43
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Frontiere_dis_base Classe representant une frontiere discretisee.
static int dimension
Definition Objet_U.h:99