TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Solveur_Masse_EF.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 <Solveur_Masse_EF.h>
17#include <Domaine_Cl_EF.h>
18#include <Domaine_EF.h>
19#include <Dirichlet.h>
20#include <Dirichlet_homogene.h>
21#include <Debog.h>
22#include <Equation_base.h>
23
24
25Implemente_instanciable(Solveur_Masse_EF,"Masse_EF",Solveur_Masse_base);
26
27
28// printOn()
29/////
30
32{
33 return s << que_suis_je() << " " << le_nom();
34}
35
36//// readOn
37//
38
40{
41 return s ;
42}
43
44
45
46///////////////////////////////////////////////////////////////
47//
48// Implementation of the Solveur_Masse_EF class functions
49//
50//////////////////////////////////////////////////////////////
51
52
53DoubleTab& Solveur_Masse_EF::appliquer_impl(DoubleTab& sm) const
54{
55 Debog::verifier("Solveur_Masse_EF::appliquer deb, sm=",sm);
56 const Domaine_Cl_EF& domaine_Cl_EF = ref_cast(Domaine_Cl_EF,le_dom_Cl_EF.valeur());
57 const Domaine_EF& domaine_EF = le_dom_EF.valeur();
58 const DoubleVect& volumes_sommets_thilde = domaine_EF.volumes_sommets_thilde();
59
60 // const DoubleVect& porosite_sommet = domaine_EF.porosite_sommet();
61 int nfa = domaine_EF.nb_som();
62 int nbsom=domaine_EF.nb_som();
63 int face;
64 if (nfa != sm.dimension(0))
65 {
66 Cerr << "error in Solveur_Masse_EF : ";
67 Cerr << "nombre de faces : " << nfa
68 << " taille du second membre : " << sm.dimension(0) << finl;
69 exit();
70 }
71 const IntTab& faces_sommets=domaine_EF.face_sommets();
72 int nb_som_face=faces_sommets.dimension(1);
73 if (sm.nb_dim() == 1)
74 {
75 // Process standard faces that do not carry boundary conditions
76
77 for (int som=0; som<nbsom; som++)
78 {
79 sm(som) /= (volumes_sommets_thilde(som));
80
81 }
82
83 // Process non-standard faces
84 // boundary faces are non-standard faces that may carry boundary conditions
85 // non-standard internal faces do not carry boundary conditions
86
87 // Process boundary conditions
88 int nb_cl=domaine_Cl_EF.nb_cond_lim();
89 for (int n_bord=0; n_bord<nb_cl; n_bord++)
90 {
91
92 const Cond_lim& la_cl = domaine_Cl_EF.les_conditions_limites(n_bord);
93 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
94 int num1 = le_bord.num_premiere_face();
95 int num2 = num1 + le_bord.nb_faces();
96
97 if ( (sub_type(Dirichlet,la_cl.valeur()))
98 ||
99 (sub_type(Dirichlet_homogene,la_cl.valeur()))
100 )
101 // For Dirichlet faces, set sm to 0
102 for (face=num1; face<num2; face++)
103 for (int s=0; s<nb_som_face; s++)
104 {
105 int som=faces_sommets(face,s);
106 sm(som) =0;
107 }
108 }
109 }
110
111
112 else
113 {
114 int nbcomp = sm.dimension(1);
115 // Process standard faces that do not carry boundary conditions
116
117 for (int som=0; som<nbsom; som++)
118 {
119 for (int comp=0; comp<nbcomp; comp++)
120 sm(som,comp) /= (volumes_sommets_thilde(som));
121
122 }
123
124 // Process non-standard faces
125 // boundary faces are non-standard faces that may carry boundary conditions
126 // non-standard internal faces do not carry boundary conditions
127
128 // Process boundary conditions
129 if (domaine_Cl_EF.equation().inconnue().nature_du_champ()==vectoriel)
130 domaine_Cl_EF.imposer_symetrie(sm);
131 int nb_cl=domaine_Cl_EF.nb_cond_lim();
132 for (int n_bord=0; n_bord<nb_cl; n_bord++)
133 {
134
135 const Cond_lim& la_cl = domaine_Cl_EF.les_conditions_limites(n_bord);
136 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
137 int num1 = le_bord.num_premiere_face();
138 int num2 = num1 + le_bord.nb_faces();
139
140 if ( (sub_type(Dirichlet,la_cl.valeur()))
141 ||
142 (sub_type(Dirichlet_homogene,la_cl.valeur()))
143 )
144 // For Dirichlet faces, set sm to 0
145 for (face=num1; face<num2; face++)
146 for (int s=0; s<nb_som_face; s++)
147 {
148 int som=faces_sommets(face,s);
149 for (int comp=0; comp<nbcomp; comp++)
150 sm(som,comp) =0;
151 }
152 }
153 }
154
155
157 Debog::verifier("Solveur_Masse_EF::appliquer, sm=",sm);
158 return sm;
159}
160
161
162//
164{
165 le_dom_EF = ref_cast(Domaine_EF, le_dom_dis_base);
166}
167
169{
170 le_dom_Cl_EF = ref_cast(Domaine_Cl_EF, le_dom_Cl_dis_base);
171}
172
173
174
175
176Matrice_Base& Solveur_Masse_EF::ajouter_masse(double dt, Matrice_Base& matrice, int penalisation) const
177{
178 if (penalisation||(le_dom_Cl_EF->equation().inconnue().nature_du_champ()!=vectoriel))
179 return Solveur_Masse_base::ajouter_masse(dt,matrice,penalisation);
180 // Otherwise temporarily change the field type so that appliquer_impl does not project onto n.
181 Champ_Inc_base& inco=ref_cast_non_const( Champ_Inc_base,le_dom_Cl_EF->equation().inconnue());
182 inco.fixer_nature_du_champ(multi_scalaire);
183 Solveur_Masse_base::ajouter_masse(dt,matrice,penalisation);
184 inco.fixer_nature_du_champ(vectoriel);
185 return matrice;
186
187
188}
189
190
191DoubleTab& Solveur_Masse_EF::ajouter_masse(double dt, DoubleTab& x, const DoubleTab& y, int penalisation, bool use_old_volumes) const
192{
193 if (penalisation||(le_dom_Cl_EF->equation().inconnue().nature_du_champ()!=vectoriel))
194 return Solveur_Masse_base::ajouter_masse(dt,x,y,penalisation, use_old_volumes);
195
196 // Otherwise temporarily change the field type so that appliquer_impl does not project onto n.
197 Champ_Inc_base& inco=ref_cast_non_const( Champ_Inc_base,le_dom_Cl_EF->equation().inconnue());
198 inco.fixer_nature_du_champ(multi_scalaire);
199 Solveur_Masse_base::ajouter_masse(dt,x,y,penalisation, use_old_volumes);
200 inco.fixer_nature_du_champ(vectoriel);
201 return x;
202}
Class Champ_Inc_base.
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
static void verifier(const char *const msg, double)
Definition Debog.cpp:21
Classe Dirichlet_homogene This class is the base class of the hierarchy of homogeneous Dirichlet-type...
Dirichlet This class is the base class of the hierarchy of Dirichlet-type boundary conditions.
Definition Dirichlet.h:31
void imposer_symetrie(DoubleTab &, int tous_les_sommets_sym=0) const
Imposes symmetry conditions, i.e. cancels the field components along the normal(s).
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
int nb_cond_lim() const
Returns the number of boundary conditions.
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
class Domaine_EF
Definition Domaine_EF.h:56
const DoubleVect & volumes_sommets_thilde() const
Definition Domaine_EF.h:83
int face_sommets(int i, int j) const
Returns the index of the i-th vertex of face num_face.
Definition Domaine_VF.h:582
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
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
virtual Nature_du_champ fixer_nature_du_champ(Nature_du_champ nat)
Sets the nature of a field: scalar, multiscalar, vectorial.
virtual Nature_du_champ nature_du_champ() const
Definition Field_base.h:77
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_premiere_face() const
Definition Front_VF.h:63
Matrice_Base class - Base class of the matrix hierarchy.
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
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
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
void associer_domaine_cl_dis_base(const Domaine_Cl_dis_base &) override
Matrice_Base & ajouter_masse(double dt, Matrice_Base &matrice, int penalisation=1) const override
DoubleTab & appliquer_impl(DoubleTab &) const override
void associer_domaine_dis_base(const Domaine_dis_base &) override
Solveur_Masse_base Represents the mass matrix of an equation.
virtual Matrice_Base & ajouter_masse(double dt, Matrice_Base &matrice, int penalisation=1) 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
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")