TrioCFD 1.9.9_beta
TrioCFD documentation
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 * @brief Field corresponding to an unknown described by its tangential components on dual faces (upstream-downstream line, e.g. velocity).
26 * Face fluxes are accessible via the valeurs_normales() methods, with automatic synchronization.
27 * Degrees of freedom: tangential components on dual faces.
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; /* request addition of auxiliary variables (\vec v at 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 of velocity at faces -> velocity at elements
51 void update_ve(DoubleTab& val) const; //first-order
52
53 void init_ve2() const; //second-order -> using a matrix
54 mutable IntTab ve2d, ve2j, ve2bj;
55 mutable DoubleTab ve2c, ve2bc;
56 void update_ve2(DoubleTab& val, int incr = 0) const;
57
58 /* utility for computing source terms: computes the vector v_e + n_f (v_f - v_e . n_f)
59 returns: the vector, its norm and its derivatives with respect to v_e and 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
Computes the trace of a field on a boundary at time 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
Causes an error! Must be overridden by derived classes.
DoubleTab & valeur_aux_elems(const DoubleTab &positions, const IntVect &polys, DoubleTab &result) const override
Causes an error! Must be overridden by derived classes.
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
Restores an Objet_U from an input stream. Virtual method to override.
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
Returns the array of field values at the current time.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Frontiere_dis_base Class representing a discretized boundary.
static int dimension
Definition Objet_U.h:94