TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Masse_VDF_Elem.cpp
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#include <Masse_VDF_Elem.h>
17#include <Equation_base.h>
18#include <Pb_Multiphase.h>
19#include <Milieu_base.h>
20#include <Domaine_Cl_VDF.h>
21#include <Domaine_VDF.h>
22
23Implemente_instanciable(Masse_VDF_Elem,"Masse_VDF_P0_VDF",Masse_VDF_base);
24
25Sortie& Masse_VDF_Elem::printOn(Sortie& s) const { return s << que_suis_je() << " " << le_nom(); }
26
27Entree& Masse_VDF_Elem::readOn(Entree& s) { return s ; }
28
30{
31 associer_masse_proto(*this, le_dom_VDF.valeur());
32 use_proto_ = sub_type(Pb_Multiphase, equation().probleme()) || equation().que_suis_je().debute_par("Equation_flux");
33 if (use_proto_) preparer_calcul_proto();
34}
35
36DoubleTab& Masse_VDF_Elem::appliquer_impl(DoubleTab& sm) const
37{
38 if (use_proto_) return appliquer_impl_proto(sm);
39 else
40 {
41 const Domaine_VDF& domaine_VDF = le_dom_VDF.valeur();
42 const DoubleVect& volumes = domaine_VDF.volumes(), &porosite_elem = equation().milieu().porosite_elem();
43 int nb_elem = domaine_VDF.nb_elem();
44 if (nb_elem == 0)
45 {
47 return sm;
48 }
49 int nb_comp = sm.size() / nb_elem;
50 int nb_dim = sm.nb_dim();
51 assert((nb_comp * nb_elem == sm.size()) || (nb_dim == 3));
52 if (nb_dim == 1)
53 for (int num_elem = 0; num_elem < nb_elem; num_elem++)
54 sm(num_elem) /= (volumes(num_elem) * porosite_elem(num_elem));
55 else if (nb_dim == 2)
56 {
57 for (int num_elem = 0; num_elem < nb_elem; num_elem++)
58 for (int k = 0; k < nb_comp; k++)
59 sm(num_elem, k) /= (volumes(num_elem) * porosite_elem(num_elem));
60 }
61 else if (sm.nb_dim() == 3)
62 {
63 //int d0=sm.dimension(0);
64 int d1 = sm.dimension(1);
65 int d2 = sm.dimension(2);
66 for (int num_elem = 0; num_elem < nb_elem; num_elem++)
67 for (int k = 0; k < d1; k++)
68 for (int d = 0; d < d2; d++)
69 sm(num_elem, k, d) /= (volumes(num_elem) * porosite_elem(num_elem));
70 }
71 else
72 {
73 Cerr << "Masse_VDF_Elem::appliquer cannot be applied to a DoubleTab with " << sm.nb_dim() << " dimensions" << finl;
75 }
77 return sm;
78 }
79}
80
81void Masse_VDF_Elem::dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl) const
82{
83 if (use_proto_)
84 dimensionner_blocs_proto(matrices, semi_impl);
85 else
86 Masse_VDF_base::dimensionner_blocs(matrices, semi_impl);
87}
88
89void Masse_VDF_Elem::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, double dt, const tabs_t& semi_impl, int resoudre_en_increments) const
90{
91 if (use_proto_)
92 ajouter_blocs_proto(matrices, secmem, dt, semi_impl, resoudre_en_increments);
93 else
94 Masse_VDF_base::ajouter_blocs(matrices, secmem, dt, semi_impl, resoudre_en_increments);
95}
class Domaine_VDF
Definition Domaine_VDF.h:61
double volumes(int i) const
Definition Domaine_VF.h:113
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Milieu_base & milieu() const =0
void preparer_calcul() override
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl={}) const override
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, double dt, const tabs_t &semi_impl, int resoudre_en_increments) const override
DoubleTab & appliquer_impl(DoubleTab &) const override
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, double dt, const tabs_t &semi_impl, int resoudre_en_increments) const override
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl) const override
DoubleVect & porosite_elem()
Definition Milieu_base.h:58
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
virtual int debute_par(const char *const n) const
Definition Nom.cpp:314
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 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
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Multiphase thermohydraulics problem of type "3*N equations":
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
void associer_masse_proto(const Solveur_Masse_base &, const Domaine_VF &)
void dimensionner_blocs_proto(matrices_t, const tabs_t &semi_impl={}) const
void ajouter_blocs_proto(matrices_t, DoubleTab &, double, const tabs_t &, int) const
DoubleTab & appliquer_impl_proto(DoubleTab &) const
Base class for output streams.
Definition Sortie.h:52
int nb_dim() const
Definition TRUSTTab.h:199
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
_SIZE_ size() const
Definition TRUSTVect.tpp:45
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")