TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Solveur_Masse_Face_proto.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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 <Solveur_Masse_Face_proto.h>
17#include <Masse_ajoutee_base.h>
18#include <Pb_Multiphase.h>
19#include <Matrix_tools.h>
20#include <TRUSTTrav.h>
21#include <Domaine_VF.h>
22
24{
25 solv_mass_ = sm;
26 le_dom_ = zvf;
27}
28
30{
31 const Domaine_VF& domaine = le_dom_.valeur();
32 const IntTab& f_e = domaine.face_voisins();
33 const DoubleVect& pf = solv_mass_->equation().milieu().porosite_face(), &vf = domaine.volumes_entrelaces();
34 const DoubleTab *a_r = sub_type(QDM_Multiphase, solv_mass_->equation()) ? &ref_cast(Pb_Multiphase, solv_mass_->equation().probleme()).equation_masse().champ_conserve().passe() : nullptr,
35 &vfd = domaine.volumes_entrelaces_dir();
36 int i, e, f, n, N = solv_mass_->equation().inconnue().valeurs().line_size();
37 double fac;
38
39 //face velocities
40 for (f = 0; f < domaine.nb_faces(); f++)
41 for (n = 0; n < N; n++)
42 {
43 for (fac = 0, i = 0; i < 2; i++)
44 if ((e = f_e(f, i)) >= 0)
45 fac += vfd(f, i) / vf(f) * (a_r ? (*a_r)(e, n) : 1);
46 if (fac > 1e-10)
47 sm(f, n) /= pf(f) * vf(f) * fac; //computed velocity
48 else
49 sm(f, n) = 0; //evanescence case
50 }
51
53 return sm;
54}
55
56void Solveur_Masse_Face_proto::dimensionner_blocs_proto(matrices_t matrices, const tabs_t& semi_impl, const bool allocate, Stencil& sten) const
57{
58 const std::string& nom_inc = solv_mass_->equation().inconnue().le_nom().getString();
59 if (!matrices.count(nom_inc)) return; //nothing to do
60
61 Matrice_Morse& mat = *matrices.at(nom_inc), mat2;
62 const Domaine_VF& domaine = le_dom_.valeur();
63 const DoubleTab& inco = solv_mass_->equation().inconnue().valeurs();
64 const Pb_Multiphase *pbm = sub_type(Pb_Multiphase, solv_mass_->equation().probleme()) ? &ref_cast(Pb_Multiphase, solv_mass_->equation().probleme()) : nullptr;
65 const Masse_ajoutee_base *corr = pbm && pbm->has_correlation("masse_ajoutee") ? &ref_cast(Masse_ajoutee_base, pbm->get_correlation("masse_ajoutee")) : nullptr;
66 int i, f, m, n, N = inco.line_size();
67
68 for (f = 0, i = 0; f < domaine.nb_faces(); f++)
69 for (n = 0; n < N; n++, i++) //real faces
70 if (corr)
71 for (m = 0; m < N; m++) sten.append_line(i, N * f + m);
72 else sten.append_line(i, i);
73
74 if (allocate)
75 {
77 mat.nb_colonnes() ? mat += mat2 : mat = mat2;
78 }
79}
80
81void Solveur_Masse_Face_proto::ajouter_blocs_proto(matrices_t matrices, DoubleTab& secmem, double dt, const tabs_t& semi_impl, int resoudre_en_increments) const
82{
83 const DoubleTab& inco = solv_mass_->equation().inconnue().valeurs(), &passe = solv_mass_->equation().inconnue().passe();
84 Matrice_Morse *mat = matrices[solv_mass_->equation().inconnue().le_nom().getString()]; //optional
85 const Domaine_VF& domaine = le_dom_.valeur();
86 const IntTab& f_e = domaine.face_voisins();
87 const DoubleVect& pf = solv_mass_->equation().milieu().porosite_face(), &vf = domaine.volumes_entrelaces();
88 const Pb_Multiphase *pbm = sub_type(Pb_Multiphase, solv_mass_->equation().probleme()) ? &ref_cast(Pb_Multiphase, solv_mass_->equation().probleme()) : nullptr;
89 const DoubleTab& vfd = domaine.volumes_entrelaces_dir(), &rho = solv_mass_->equation().milieu().masse_volumique().passe(),
90 *alpha = pbm ? &pbm->equation_masse().inconnue().passe() : nullptr, *a_r = pbm ? &pbm->equation_masse().champ_conserve().passe() : nullptr;
91 const Masse_ajoutee_base *corr = pbm && pbm->has_correlation("masse_ajoutee") ? &ref_cast(Masse_ajoutee_base, pbm->get_correlation("masse_ajoutee")) : nullptr;
92 int i, e, f, m, n, N = inco.line_size(), cR = rho.dimension_tot(0) == 1;
93
94 /* faces: if BCs, no alpha * rho product in multiphase */
95 DoubleTrav masse(N, N), masse_e(N, N); //alpha * rho mass, contribution
96 for (f = 0; f < domaine.nb_faces(); f++) //real faces
97 {
98 if (!pbm)
99 for (masse = 0, n = 0; n < N; n++) masse(n, n) = vf(f); //not Pb_Multiphase or BC -> no alpha * rho
100 else for (masse = 0, i = 0; i < 2; i++)
101 if ((e = f_e(f, i)) >= 0)
102 {
103 for (masse_e = 0, n = 0; n < N; n++) masse_e(n, n) = (*a_r)(e, n); //diagonal part
104 if (corr) corr->ajouter(&(*alpha)(e, 0), &rho(!cR * e, 0), masse_e); //added mass part
105 for (n = 0; n < N; n++)
106 for (m = 0; m < N; m++) masse(n, m) += vfd(f, i) * masse_e(n, m); //contribution to face alpha * rho
107 }
108 for (n = 0; n < N; n++)
109 {
110 for (m = 0; m < N; m++) secmem(f, n) += pf(f) / dt * masse(n, m) * (passe(f, m) - resoudre_en_increments * inco(f, m));
111 if (mat)
112 for (m = 0; m < N; m++)
113 if (masse(n, m)) (*mat)(N * f + n, N * f + m) += pf(f) / dt * masse(n, m);
114 }
115 }
116}
DoubleTab & passe(int i=1) override
Returns field values at instant t-i.
class Domaine_VF
Definition Domaine_VF.h:44
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
Champ_Inc_base & champ_conserve() const
virtual const Champ_Inc_base & inconnue() const =0
Probleme_base & probleme()
Returns the problem associated with the equation.
Added-mass correlation of the form: alpha_k rho_k Dv_k / Dt -> alpha_k rho_k Dv_k / Dt + sum_l ma(k,...
virtual void ajouter(const double *alpha, const double *rho, DoubleTab &a_r) const =0
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
int nb_colonnes() const override
Return local number of columns (=size on the current proc).
static void allocate_morse_matrix(const int nb_lines, const int nb_columns, const Stencil &stencil, Matrice_Morse &matrix, const bool &attach_stencil_to_matrix=false)
const std::string & getString() const
Definition Nom.h:92
virtual const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Objet_U.cpp:317
Multiphase thermohydraulics problem of type "3*N equations":
const Equation_base & equation(int) const override
Returns the equation at index i (const version).
virtual Equation_base & equation_masse()
int has_correlation(std::string nom_correlation) const
const Correlation_base & get_correlation(std::string nom_correlation) const
Carries the terms of the momentum equation for multiphase flow without turbulence modelling.
void associer_masse_proto(const Solveur_Masse_base &, const Domaine_VF &)
void ajouter_blocs_proto(matrices_t matrices, DoubleTab &secmem, double dt, const tabs_t &semi_impl, int resoudre_en_increments) const
void dimensionner_blocs_proto(matrices_t matrices, const tabs_t &semi_impl, const bool allocate, Stencil &) const
DoubleTab & appliquer_impl_proto(DoubleTab &) const
Solveur_Masse_base Represents the mass matrix of an equation.
void append_line(_TYPE_)
Definition TRUSTTab.tpp:213
_SIZE_ size_totale() const
Definition TRUSTVect.tpp:61
int line_size() const
Definition TRUSTVect.tpp:67
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")