TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Masse_VDF_base.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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_base.h>
17#include <Domaine_Cl_VDF.h>
18#include <Domaine_VDF.h>
19#include <Dirichlet.h>
20#include <Dirichlet_homogene.h>
21#include <Symetrie.h>
22#include <Debog.h>
23#include <Equation_base.h>
24#include <TRUSTTrav.h>
25
26Implemente_base_sans_constructeur(Masse_VDF_base,"Masse_VDF_base",Solveur_Masse_base);
27Masse_VDF_base::Masse_VDF_base() : penalisation_matrice_(0),penalisation_secmem_(0) {}
28
29Sortie& Masse_VDF_base::printOn(Sortie& s) const { return s << que_suis_je() << " " << le_nom(); }
30
31Entree& Masse_VDF_base::readOn(Entree& s) { return s ; }
32
33void Masse_VDF_base::dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl) const
34{
35 const std::string& nom_inc = equation().inconnue().le_nom().getString();
36 if (!matrices.count(nom_inc)) return; //rien a faire
37 Matrice_Morse& mat = *matrices.at(nom_inc);
38 const DoubleTab& champ_inconnue = equation().inconnue().valeurs();
39 int size = champ_inconnue.dimension_tot(0) * champ_inconnue.line_size();
40
41 IntTab indice(size, 2);
42 for(int i=0; i<size; ++i)
43 {
44 indice(i,0) = indice(i,1) = i;
45 }
46 mat.dimensionner(indice);
47}
48
49void Masse_VDF_base::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, double dt, const tabs_t& semi_impl, int resoudre_en_increments) const
50{
51 const std::string& nom_inco = equation().inconnue().le_nom().getString();
52 const DoubleTab& passe = semi_impl.count(nom_inco) ? semi_impl.at(nom_inco) : equation().inconnue().passe();
53 const DoubleTab& inco = equation().inconnue().valeurs();
54 Matrice_Morse *mat = matrices.count(nom_inco) ? matrices.at(nom_inco) : nullptr;
55 DoubleTrav diag(inco);
56
57 const int sz = equation().inconnue().valeurs().dimension_tot(0) * diag.line_size();
58 diag = 1.;
59 appliquer(diag); // M-1
60 int prems = 0;
62 {
63 if (mat && penalisation_matrice_ == 0)
64 {
65 double penal = 0;
66 for (int i = 0; i < sz; i++)
67 penal = std::max(penal, (*mat)(i, i));
68 penal = mp_max(penal);
69 penalisation_matrice_ = (mp_max_vect(diag) / dt + penal) * 1.e3;
70 prems = 1;
71 }
72 if (penalisation_secmem_ == 0)
73 penalisation_secmem_ = mp_max_vect(diag) * 1.e3;
74 }
75 else
76 {
79 }
80
81 for (int i = 0; i < sz; i++)
82 {
83 if (diag.addr()[i])
84 {
85 if (mat)
86 (*mat)(i, i) += 1. / (diag.addr()[i] * dt); // M/dt
87 secmem.addr()[i] += 1. / (diag.addr()[i] * dt) * passe.addr()[i];
88 }
89 else
90 {
91 if (prems)
92 {
93 if (mat)
94 (*mat)(i, i) += penalisation_matrice_;
95 prems = 0;
96 }
97 if (mat)
98 (*mat)(i, i) += penalisation_matrice_ / dt;
99 secmem.addr()[i] = penalisation_secmem_ * passe.addr()[i];
100 }
101 }
102}
103
105{
106 le_dom_VDF = ref_cast(Domaine_VDF, le_dom_dis_base);
107}
108
110{
111 le_dom_Cl_VDF = ref_cast(Domaine_Cl_VDF, le_dom_Cl_dis_base);
112}
DoubleTab & passe(int i=1) override
Renvoie les valeurs du champs a l'instant t-i.
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
class Domaine_Cl_VDF
classe Domaine_Cl_dis_base Les objets Domaine_Cl_dis_base representent les conditions aux limites
class Domaine_VDF
Definition Domaine_VDF.h:64
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Champ_Inc_base & inconnue() const =0
const Nom & le_nom() const override
Renvoie le nom du champ.
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, double dt, const tabs_t &semi_impl, int resoudre_en_increments) const override
void associer_domaine_dis_base(const Domaine_dis_base &) override
void associer_domaine_cl_dis_base(const Domaine_Cl_dis_base &) override
double penalisation_matrice_
double penalisation_secmem_
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl) const override
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
void dimensionner(int n, _SIZE_ nnz)
Size the matrix with n lines and n columns and nnz zero-values coefficients.
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
const std::string & getString() const
Definition Nom.h:92
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual const Nom & le_nom() const
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Definition Objet_U.cpp:319
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static double mp_max(double)
Definition Process.cpp:376
classe Solveur_Masse_base Represente la matrice de masse d'une equation.
virtual DoubleTab & appliquer(DoubleTab &) const
renvoie appliquer_impl(x/coeffient_temporelle) si on a un coefficient temporel sinon renvoie applique...
Classe de base des flux de sortie.
Definition Sortie.h:52
_TYPE_ * addr()
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
int line_size() const
Definition TRUSTVect.tpp:67